diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml
index 02852656b..2a2cbc348 100644
--- a/.github/workflows/cicd.yml
+++ b/.github/workflows/cicd.yml
@@ -90,7 +90,8 @@ jobs:
{ name: "Testcontainers.Sftp", runs-on: "ubuntu-22.04" },
{ name: "Testcontainers.Weaviate", runs-on: "ubuntu-22.04" },
{ name: "Testcontainers.WebDriver", runs-on: "ubuntu-22.04" },
- { name: "Testcontainers.Xunit", runs-on: "ubuntu-22.04" }
+ { name: "Testcontainers.Xunit", runs-on: "ubuntu-22.04" },
+ { name: "Testcontainers.XunitV3", runs-on: "ubuntu-22.04" }
]
runs-on: ${{ matrix.test-projects.runs-on }}
diff --git a/Directory.Packages.props b/Directory.Packages.props
index c73d7305c..710c79396 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -20,6 +20,7 @@
+
diff --git a/Testcontainers.sln b/Testcontainers.sln
index 720ad9de1..5601722da 100644
--- a/Testcontainers.sln
+++ b/Testcontainers.sln
@@ -239,6 +239,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.WebDriver.Te
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Xunit.Tests", "tests\Testcontainers.Xunit.Tests\Testcontainers.Xunit.Tests.csproj", "{E901DF14-6F05-4FC2-825A-3055FAD33561}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.XunitV3.Tests", "tests\Testcontainers.XunitV3.Tests\Testcontainers.XunitV3.Tests.csproj", "{B2E8B7FB-7D1E-4DD3-A25E-34DE4386B1EB}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -700,6 +702,10 @@ Global
{E901DF14-6F05-4FC2-825A-3055FAD33561}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E901DF14-6F05-4FC2-825A-3055FAD33561}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E901DF14-6F05-4FC2-825A-3055FAD33561}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B2E8B7FB-7D1E-4DD3-A25E-34DE4386B1EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B2E8B7FB-7D1E-4DD3-A25E-34DE4386B1EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B2E8B7FB-7D1E-4DD3-A25E-34DE4386B1EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B2E8B7FB-7D1E-4DD3-A25E-34DE4386B1EB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{5365F780-0E6C-41F0-B1B9-7DC34368F80C} = {673F23AE-7694-4BB9-ABD4-136D6C13634E}
@@ -815,5 +821,6 @@ Global
{DDB41BC8-5826-4D97-9C5F-001151E3FFD6} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF}
{EBA72C3B-57D5-43FF-A5B4-3D55B3B6D4C2} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF}
{E901DF14-6F05-4FC2-825A-3055FAD33561} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF}
+ {B2E8B7FB-7D1E-4DD3-A25E-34DE4386B1EB} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF}
EndGlobalSection
EndGlobal
diff --git a/tests/Testcontainers.Databases.Tests/Testcontainers.Databases.Tests.csproj b/tests/Testcontainers.Databases.Tests/Testcontainers.Databases.Tests.csproj
index 7ce264f72..61e5f960b 100644
--- a/tests/Testcontainers.Databases.Tests/Testcontainers.Databases.Tests.csproj
+++ b/tests/Testcontainers.Databases.Tests/Testcontainers.Databases.Tests.csproj
@@ -12,6 +12,8 @@
+
+
\ No newline at end of file
diff --git a/tests/Testcontainers.Xunit.Tests/AlphabeticalTestCaseOrderer.cs b/tests/Testcontainers.Xunit.Tests/AlphabeticalTestCaseOrderer.cs
index e2e0a5022..51b2a3870 100644
--- a/tests/Testcontainers.Xunit.Tests/AlphabeticalTestCaseOrderer.cs
+++ b/tests/Testcontainers.Xunit.Tests/AlphabeticalTestCaseOrderer.cs
@@ -2,8 +2,17 @@ namespace Testcontainers.Xunit.Tests;
public class AlphabeticalTestCaseOrderer : ITestCaseOrderer
{
- public IEnumerable OrderTestCases(IEnumerable testCases) where TTestCase : ITestCase
+#if XUNIT_V3
+ public IReadOnlyCollection OrderTestCases(IReadOnlyCollection testCases)
+ where TTestCase : notnull, ITestCase
+ {
+ return testCases.OrderBy(testCase => testCase.TestMethod?.MethodName).ToImmutableList();
+ }
+#else
+ public IEnumerable OrderTestCases(IEnumerable testCases)
+ where TTestCase : ITestCase
{
return testCases.OrderBy(testCase => testCase.TestMethod.Method.Name);
}
+#endif
}
\ No newline at end of file
diff --git a/tests/Testcontainers.Xunit.Tests/PostgreSqlContainer.cs b/tests/Testcontainers.Xunit.Tests/PostgreSqlContainer.cs
index 22089fd9a..e37e17ac1 100644
--- a/tests/Testcontainers.Xunit.Tests/PostgreSqlContainer.cs
+++ b/tests/Testcontainers.Xunit.Tests/PostgreSqlContainer.cs
@@ -46,7 +46,11 @@ public void ImageShouldMatchDefaultModuleImage()
public async Task Test1()
{
const string sql = "SELECT title FROM album ORDER BY album_id";
+#if XUNIT_V3
+ using var connection = await OpenConnectionAsync(TestContext.Current.CancellationToken);
+#else
using var connection = await OpenConnectionAsync();
+#endif
var title = await connection.QueryFirstAsync(sql);
Assert.Equal("For Those About To Rock We Salute You", title);
}
diff --git a/tests/Testcontainers.Xunit.Tests/RedisContainerTest`1.cs b/tests/Testcontainers.Xunit.Tests/RedisContainerTest`1.cs
index 6dfe802de..5115623fc 100644
--- a/tests/Testcontainers.Xunit.Tests/RedisContainerTest`1.cs
+++ b/tests/Testcontainers.Xunit.Tests/RedisContainerTest`1.cs
@@ -12,7 +12,11 @@ protected override RedisBuilder Configure(RedisBuilder builder)
}
// # --8<-- [end:ConfigureRedisContainer]
+#if XUNIT_V3
+[TestCaseOrderer(ordererType: typeof(Testcontainers.Xunit.Tests.AlphabeticalTestCaseOrderer))]
+#else
[TestCaseOrderer(ordererTypeName: "Testcontainers.Xunit.Tests.AlphabeticalTestCaseOrderer", ordererAssemblyName: "Testcontainers.Xunit.Tests")]
+#endif
public sealed partial class RedisContainerTest
{
[Fact]
diff --git a/tests/Testcontainers.Xunit.Tests/RedisContainerTest`2.cs b/tests/Testcontainers.Xunit.Tests/RedisContainerTest`2.cs
index 36889df8b..8465fcf65 100644
--- a/tests/Testcontainers.Xunit.Tests/RedisContainerTest`2.cs
+++ b/tests/Testcontainers.Xunit.Tests/RedisContainerTest`2.cs
@@ -17,7 +17,11 @@ public sealed partial class RedisContainerTest(RedisContainerFixture fixture)
: IClassFixture;
// # --8<-- [end:InjectContainerFixture]
+#if XUNIT_V3
+[TestCaseOrderer(ordererType: typeof(Testcontainers.Xunit.Tests.AlphabeticalTestCaseOrderer))]
+#else
[TestCaseOrderer(ordererTypeName: "Testcontainers.Xunit.Tests.AlphabeticalTestCaseOrderer", ordererAssemblyName: "Testcontainers.Xunit.Tests")]
+#endif
public sealed partial class RedisContainerTest
{
[Fact]
diff --git a/tests/Testcontainers.Xunit.Tests/Testcontainers.Xunit.Tests.csproj b/tests/Testcontainers.Xunit.Tests/Testcontainers.Xunit.Tests.csproj
index 423bfee78..f72f16ae8 100644
--- a/tests/Testcontainers.Xunit.Tests/Testcontainers.Xunit.Tests.csproj
+++ b/tests/Testcontainers.Xunit.Tests/Testcontainers.Xunit.Tests.csproj
@@ -7,15 +7,17 @@
-
+
+
+
+
+
-
-
diff --git a/tests/Testcontainers.Xunit.Tests/Usings.cs b/tests/Testcontainers.Xunit.Tests/Usings.cs
index 8ebda9462..533aa3b5f 100644
--- a/tests/Testcontainers.Xunit.Tests/Usings.cs
+++ b/tests/Testcontainers.Xunit.Tests/Usings.cs
@@ -1,4 +1,5 @@
global using System.Collections.Generic;
+global using System.Collections.Immutable;
global using System.Data.Common;
global using System.Linq;
global using System.Threading.Tasks;
@@ -9,5 +10,9 @@
global using Testcontainers.PostgreSql;
global using Testcontainers.Redis;
global using Xunit;
+#if XUNIT_V3
+global using Xunit.v3;
+#else
global using Xunit.Abstractions;
+#endif
global using Xunit.Sdk;
\ No newline at end of file
diff --git a/tests/Testcontainers.XunitV3.Tests/.editorconfig b/tests/Testcontainers.XunitV3.Tests/.editorconfig
new file mode 100644
index 000000000..6f066619d
--- /dev/null
+++ b/tests/Testcontainers.XunitV3.Tests/.editorconfig
@@ -0,0 +1 @@
+root = true
\ No newline at end of file
diff --git a/tests/Testcontainers.XunitV3.Tests/Testcontainers.XunitV3.Tests.csproj b/tests/Testcontainers.XunitV3.Tests/Testcontainers.XunitV3.Tests.csproj
new file mode 100644
index 000000000..cd6595f8c
--- /dev/null
+++ b/tests/Testcontainers.XunitV3.Tests/Testcontainers.XunitV3.Tests.csproj
@@ -0,0 +1,32 @@
+
+
+ net9.0
+ false
+ false
+ Exe
+ $(DefineConstants);XUNIT_V3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ PreserveNewest
+
+
+
\ No newline at end of file