Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<PackageVersion Include="ReflectionMagic" Version="5.0.1"/>
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.2"/>
<PackageVersion Include="xunit" Version="2.9.3"/>
<PackageVersion Include="xunit.v3" Version="2.0.1"/>
<!-- xUnit.net extensibility for Testcontainers.Xunit and Testcontainers.XunitV3 packages: -->
<PackageVersion Include="xunit.extensibility.execution" Version="2.9.3"/>
<PackageVersion Include="xunit.v3.extensibility.core" Version="1.1.0"/>
Expand Down
7 changes: 7 additions & 0 deletions Testcontainers.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../Testcontainers.*.Tests/Testcontainers.*.Tests.csproj"/>
<ProjectReference Remove="../Testcontainers.Xunit.Tests/Testcontainers.Xunit.Tests.csproj"/>
<ProjectReference Remove="../Testcontainers.XunitV3.Tests/Testcontainers.XunitV3.Tests.csproj"/>
<ProjectReference Remove="Testcontainers.Databases.Tests.csproj"/>
</ItemGroup>
</Project>
11 changes: 10 additions & 1 deletion tests/Testcontainers.Xunit.Tests/AlphabeticalTestCaseOrderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@ namespace Testcontainers.Xunit.Tests;

public class AlphabeticalTestCaseOrderer : ITestCaseOrderer
{
public IEnumerable<TTestCase> OrderTestCases<TTestCase>(IEnumerable<TTestCase> testCases) where TTestCase : ITestCase
#if XUNIT_V3
public IReadOnlyCollection<TTestCase> OrderTestCases<TTestCase>(IReadOnlyCollection<TTestCase> testCases)
where TTestCase : notnull, ITestCase
{
return testCases.OrderBy(testCase => testCase.TestMethod?.MethodName).ToImmutableList();
}
#else
public IEnumerable<TTestCase> OrderTestCases<TTestCase>(IEnumerable<TTestCase> testCases)
where TTestCase : ITestCase
{
return testCases.OrderBy(testCase => testCase.TestMethod.Method.Name);
}
#endif
}
4 changes: 4 additions & 0 deletions tests/Testcontainers.Xunit.Tests/PostgreSqlContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>(sql);
Assert.Equal("For Those About To Rock We Salute You", title);
}
Expand Down
4 changes: 4 additions & 0 deletions tests/Testcontainers.Xunit.Tests/RedisContainerTest`1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 4 additions & 0 deletions tests/Testcontainers.Xunit.Tests/RedisContainerTest`2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ public sealed partial class RedisContainerTest(RedisContainerFixture fixture)
: IClassFixture<RedisContainerFixture>;
// # --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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk"/>
<PackageReference Include="coverlet.collector"/>
<PackageReference Include="Dapper"/>
<PackageReference Include="xunit.runner.visualstudio"/>
<PackageReference Include="xunit"/>
<PackageReference Include="Dapper"/>
<PackageReference Include="Npgsql"/>
<PackageReference Include="StackExchange.Redis"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../../src/Testcontainers.Xunit/Testcontainers.Xunit.csproj"/>
<ProjectReference Include="../../src/Testcontainers.PostgreSql/Testcontainers.PostgreSql.csproj"/>
<ProjectReference Include="../../src/Testcontainers.Redis/Testcontainers.Redis.csproj"/>
<ProjectReference Include="../Testcontainers.Commons/Testcontainers.Commons.csproj"/>
<ProjectReference Include="../Testcontainers.Redis.Tests/Testcontainers.Redis.Tests.csproj"/>
<ProjectReference Include="../Testcontainers.PostgreSql.Tests/Testcontainers.PostgreSql.Tests.csproj"/>
</ItemGroup>
<ItemGroup>
<None Update="Chinook_PostgreSql_AutoIncrementPKs.sql">
Expand Down
5 changes: 5 additions & 0 deletions tests/Testcontainers.Xunit.Tests/Usings.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
1 change: 1 addition & 0 deletions tests/Testcontainers.XunitV3.Tests/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
root = true
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net9.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<IsPublishable>false</IsPublishable>
<OutputType>Exe</OutputType>
<DefineConstants>$(DefineConstants);XUNIT_V3</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk"/>
<PackageReference Include="coverlet.collector"/>
<PackageReference Include="xunit.runner.visualstudio"/>
<PackageReference Include="xunit.v3"/>
<PackageReference Include="Dapper"/>
<PackageReference Include="Npgsql"/>
<PackageReference Include="StackExchange.Redis"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../../src/Testcontainers.XunitV3/Testcontainers.XunitV3.csproj"/>
<ProjectReference Include="../../src/Testcontainers.PostgreSql/Testcontainers.PostgreSql.csproj"/>
<ProjectReference Include="../../src/Testcontainers.Redis/Testcontainers.Redis.csproj"/>
<ProjectReference Include="../Testcontainers.Commons/Testcontainers.Commons.csproj"/>
</ItemGroup>
<ItemGroup>
<Compile Include="../Testcontainers.Xunit.Tests/*.cs"/>
</ItemGroup>
<ItemGroup>
<None Include="../Testcontainers.Xunit.Tests/Chinook_PostgreSql_AutoIncrementPKs.sql">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>