NotoriousTest.TestContainers
4.0.0-beta.112
See the version list below for details.
dotnet add package NotoriousTest.TestContainers --version 4.0.0-beta.112
NuGet\Install-Package NotoriousTest.TestContainers -Version 4.0.0-beta.112
<PackageReference Include="NotoriousTest.TestContainers" Version="4.0.0-beta.112" />
<PackageVersion Include="NotoriousTest.TestContainers" Version="4.0.0-beta.112" />
<PackageReference Include="NotoriousTest.TestContainers" />
paket add NotoriousTest.TestContainers --version 4.0.0-beta.112
#r "nuget: NotoriousTest.TestContainers, 4.0.0-beta.112"
#:package NotoriousTest.TestContainers@4.0.0-beta.112
#addin nuget:?package=NotoriousTest.TestContainers&version=4.0.0-beta.112&prerelease
#tool nuget:?package=NotoriousTest.TestContainers&version=4.0.0-beta.112&prerelease
Clean, isolated, and maintainable integration testing for .NET
If you plan to use this NuGet package, let me know in the Tell me if you use that package ! discussion on Github ! Gaining insight into its usage is very important to me!
Summary
Purpose
Have you ever had to write and rewrite boilerplate code to set up a database, reset data between each test, or tear down containers? All that setup required to keep your integration tests fully isolated, and ensure their maintainability, reproducibility, and efficiency.
NotoriousTest removes the need to build all of that yourself.
The concept is simple:
- Create an infrastructure and implement its initialization, reset, and destruction logic.
- Add it to an environment.
- Access it directly from your integration tests.
NotoriousTest will automatically manage the lifecycle of your infrastructures. Even after the tests have crashed unexpectedly, thanks to the DoggyDog 🐶.
Hello World
Setup
First, install NuGet. Then, install the package matching your test framework:
| Framework | Package |
|---|---|
| xUnit | NotoriousTest.XUnit |
| NUnit | NotoriousTest.NUnit |
| MSTest | NotoriousTest.MSTest |
| TUnit | NotoriousTest.TUnit |
PM> Install-Package NotoriousTest.XUnit
Or from the .NET CLI:
dotnet add package NotoriousTest.XUnit
Note: .NET 8 or higher is required.
Define a Basic Infrastructure
An infrastructure represents an external dependency (database, message bus, etc.).
For now, we'll define an empty infrastructure to illustrate the setup.
You can replace MyInfrastructure with any real infrastructure later.
public class MyInfrastructure : Infrastructure
{
public override Task Initialize()
{
// Setup logic here (e.g., start a database, configure an API)
Console.WriteLine($"Setup of {nameof(MyInfrastructure)}");
return Task.CompletedTask;
}
public override Task Reset()
{
// Reset logic here (e.g., clear data, reset state)
Console.WriteLine($"Reset of {nameof(MyInfrastructure)}");
return Task.CompletedTask;
}
public override Task Destroy()
{
// Cleanup logic here (e.g., shut down services)
Console.WriteLine($"Shutdown of {nameof(MyInfrastructure)}");
return Task.CompletedTask;
}
}
📌 What this does:
- Defines a basic infrastructure with lifecycle methods.
- This is where you would add setup logic for databases, APIs, queues, etc.
Create a Test Environment
A test environment groups infrastructures together. Extend the environment class from your framework-specific package:
// xUnit
using System.Reflection;
using Xunit.Sdk;
public class MyTestEnvironment : NotoriousTest.XUnit.Environment
{
public MyTestEnvironment(IMessageSink sink) : base(sink) { }
public override Assembly CurrentAssembly => Assembly.GetExecutingAssembly();
public override async Task ConfigureEnvironment()
{
AddInfrastructure<MyInfrastructure>();
}
}
📌 What this does:
- Registers
MyInfrastructureinside the test environment. - Ensures all tests run in a clean and isolated setup.
See Multi-Framework Support for NUnit, MSTest, and TUnit equivalents.
Write your first test
Now, let's write a basic integration test using our environment.
// xUnit
public class MyIntegrationTests : NotoriousTest.XUnit.IntegrationTest<MyTestEnvironment>
{
public MyIntegrationTests(MyTestEnvironment environment) : base(environment) { }
[Fact]
public async Task ExampleTest()
{
// Retrieve the infrastructure
var infra = CurrentEnvironment.GetInfrastructure<MyInfrastructure>();
// Add test logic here (e.g., verify database state, call an API)
Assert.NotNull(infra); // Basic validation to confirm setup works
}
}
📌 What this does:
- Retrieves the test infrastructure from the environment.
- You can add real test logic (API calls, database assertions, etc.).
🚀 Running Your First Test
Now, let's run the test:
dotnet test
Expected Output
You should see something like:
Passed! 1 test successful.
If everything works, congrats! 🎉 You've successfully set up NotoriousTest.
Multi-Framework Support
NotoriousTest supports xUnit, NUnit, MSTest, and TUnit. The environment and test base classes differ per framework — everything else is identical.
NUnit
// Environment
public class MyTestEnvironment : NotoriousTest.NUnit.Environment
{
public override Assembly CurrentAssembly => Assembly.GetExecutingAssembly();
public override async Task ConfigureEnvironment()
{
AddInfrastructure<MyInfrastructure>();
}
}
// Tests
[TestFixture]
public class MyIntegrationTests : NotoriousTest.NUnit.IntegrationTest<MyTestEnvironment>
{
[Test]
public async Task ExampleTest()
{
var infra = CurrentEnvironment.GetInfrastructure<MyInfrastructure>();
Assert.That(infra, Is.Not.Null);
}
}
MSTest
// Environment
public class MyTestEnvironment : NotoriousTest.MSTest.Environment
{
public override Assembly CurrentAssembly => Assembly.GetExecutingAssembly();
public override async Task ConfigureEnvironment()
{
AddInfrastructure<MyInfrastructure>();
}
}
// Tests
[TestClass]
public class MyIntegrationTests : NotoriousTest.MSTest.IntegrationTest<MyTestEnvironment>
{
[TestMethod]
public async Task ExampleTest()
{
var infra = CurrentEnvironment.GetInfrastructure<MyInfrastructure>();
Assert.IsNotNull(infra);
}
}
TUnit
// Environment
public class MyTestEnvironment : NotoriousTest.TUnit.Environment
{
public override Assembly CurrentAssembly => Assembly.GetExecutingAssembly();
public override async Task ConfigureEnvironment()
{
AddInfrastructure<MyInfrastructure>();
}
}
// Tests
public class MyIntegrationTests : NotoriousTest.TUnit.IntegrationTest<MyTestEnvironment>
{
public MyIntegrationTests(MyTestEnvironment environment) : base(environment) { }
[Test]
public async Task ExampleTest()
{
var infra = CurrentEnvironment.GetInfrastructure<MyInfrastructure>();
await Assert.That(infra).IsNotNull();
}
}
Resources & Community
Documentation
- 📖 Core Concepts – Learn how infrastructures and environments work.
- 🔌 Integrations – See how to integrate SQL Server, TestContainers, and more.
- 📚 Examples – Hands-on use cases with real-world setups.
- 🏛️ Architecture Guidelines – Best practices for structuring your test setup.
Changelog
You can find the changelog here.
Contact
Have questions, ideas, or feedback about NotoriousTest? Feel free to reach out! I'd love to hear from you. Here's how you can get in touch:
- GitHub Issues: Open an issue to report a problem, request a feature, or share an idea.
- Email: briceschumacher21@gmail.com
- LinkedIn : Brice SCHUMACHER
The discussions tabs is now opened ! Feel free to tell me if you use the package here : https://github.com/Notorious-Coding/Notorious-Test/discussions/1 !
Other nugets i'm working on
- NotoriousClient : Notorious Client is meant to simplify the sending of HTTP requests through a fluent builder and an infinitely extensible client system.
- NotoriousModules : Notorious Modules provide a simple way to separate monolith into standalone modules.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- NotoriousTest.Core (>= 4.0.0-beta.112)
- Testcontainers (>= 4.11.0)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on NotoriousTest.TestContainers:
| Package | Downloads |
|---|---|
|
NotoriousTest.SqlServer
A SqlServer integration with NotoriousTest. |
|
|
NotoriousTest.PostgreSql
A PostgreSql integration with NotoriousTest. |
|
|
NotoriousTest.Web
Web integration tests support for NotoriousTest. |
|
|
NotoriousTest.Database
A Database integration with NotoriousTest. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.1 | 24 | 4/8/2026 |
| 4.0.1-beta.123 | 0 | 4/9/2026 |
| 4.0.1-beta.121 | 24 | 4/8/2026 |
| 4.0.1-beta.118 | 16 | 4/8/2026 |
| 4.0.0-beta.116 | 42 | 4/7/2026 |
| 4.0.0-beta.114 | 37 | 4/7/2026 |
| 4.0.0-beta.112 | 38 | 4/6/2026 |
| 4.0.0-beta.109 | 38 | 4/5/2026 |
| 4.0.0-beta.107 | 37 | 4/5/2026 |
| 4.0.0-beta.102 | 41 | 4/5/2026 |
| 4.0.0-beta.99 | 39 | 4/5/2026 |
| 4.0.0-beta.97 | 44 | 4/4/2026 |
| 4.0.0-beta.95 | 47 | 4/4/2026 |
| 4.0.0-beta.83 | 40 | 4/4/2026 |
| 4.0.0-beta.65 | 47 | 3/23/2026 |
| 4.0.0-beta.61 | 41 | 3/23/2026 |
| 4.0.0-beta.58 | 39 | 3/22/2026 |
| 4.0.0-beta.54 | 43 | 3/15/2026 |
| 4.0.0-beta.52 | 43 | 3/14/2026 |