A practical example of testing an ASP.NET Core Web API with xUnit v3 and Testcontainers.
This project uses Microsoft Testing Platform, a lightweight platform for running and managing .NET tests.
Test classes without explicit collections
|
v
AutoBucketCollectionFactory
/ \
v v
Dynamic collection Dynamic collection
\ /
v v
TestCollectionFixture
(one per collection)
|
v
ASP.NET Core test server
^
| connection string
TestAssemblyFixture
|
v
SQL Server Testcontainer
(started once per assembly)
TestAssemblyFixturestarts a SQL Server container once for the test assembly.TestCollectionFixturecreates the test application and configures it with the container's connection string.AutoBucketCollectionFactorydistributes test classes without an explicit collection across dynamic collections, helping tests run in parallel.- Tests run against the application and its SQL Server database.
dotnet test NET.slnxDocker must be running so Testcontainers can start SQL Server.