NotoriousTest 3.1.0
dotnet add package NotoriousTest --version 3.1.0
NuGet\Install-Package NotoriousTest -Version 3.1.0
<PackageReference Include="NotoriousTest" Version="3.1.0" />
<PackageVersion Include="NotoriousTest" Version="3.1.0" />
<PackageReference Include="NotoriousTest" />
paket add NotoriousTest --version 3.1.0
#r "nuget: NotoriousTest, 3.1.0"
#:package NotoriousTest@3.1.0
#addin nuget:?package=NotoriousTest&version=3.1.0
#tool nuget:?package=NotoriousTest&version=3.1.0
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
- The problem with integration testing in .NET
- NotoriousTest: The solution
- Why use NotoriousTest
- Hello World
- Resources & Community
- Other packages i'm working on
๐จ The problem with integration testing in .NET
When testing an application that relies on multiple infrastructures (databases, message buses, blob storage, FTP, SMTP...), the common approach looks like this:
- Create a WebApplicationFactory and use it as a fixture.
- Implement
IAsyncLifetimeto initialize and dispose of infrastructures. - Manage each infrastructure (SQL Server, RabbitMQ, Redis, MongoDB, etc.) within
Initializeand Dispose. - Add specific setup code inside the test constructors.
๐ This works for small projects, but as complexity increases, it becomes a nightmare:
๐ฅ The WebApplicationFactory turns into an unmanageable beast.
๐ Everything needs to be manually refactored and structured โ resulting in messy, hard-to-maintain code.
๐๏ธ Tests become slow to write and complex to maintain.
โณ Setup time skyrockets, reducing productivity.
And thatโs the real problemโintegration tests are meant to ensure the quality of our code. But if they themselves become unmanageable, the enemy of our enemy becomes our enemy.
๐ NotoriousTest: The solution
NotoriousTest introduces a modular and structured approach to isolating and managing your test infrastructures effortlessly.
โ
Each infrastructure (database, message bus, etc.) is encapsulated in its own class with a proper lifecycle (Init, Reset, Destroy).
โ
Test environments are composable โ you assemble infrastructures like Lego blocks.
โ
Automatic reset between tests ensures proper isolation.
โ
No need to bloat your WebApplicationFactory โ each infrastructure is cleanly defined.
โ
Works seamlessly with TestContainers, SQL Server, and more.
๐ The result? A testing framework that is clean, modular, maintainable, and scalable.
Why use NotoriousTest
๐น Designed for complex integration tests
Seamlessly manage multiple infrastructures like databases, message buses, blob storage, and more, without turning your test setup into a nightmare.
๐น Fully isolated and resettable environments
Ensure clean, independent tests by automatically resetting infrastructures between each runโno leftover data, no hidden side effects.
๐น Modular & reusable infrastructure components
Define each infrastructure separately and compose test environments like Lego blocks. No more bloated WebApplicationFactories!
๐น Effortless setup & minimal boilerplate
Forget complex test initialization logicโNotoriousTest takes care of instantiating, resetting, and destroying your infrastructures automatically.
๐น Compatible with TestContainers & SQL Server
Seamlessly integrates with Dockerized test environments, allowing you to spin up databases, message queues, and more in seconds.
๐น Powered by XUnit & Async Support
Leverage the flexibility of XUnitโs dependency injection and fully async infrastructure lifecycles for faster and more scalable tests.
Hello World
Setup
First, install NuGet. Then, install NotoriousTest from the package manager console:
PM> Install-Package NotoriousTest
Or from the .NET CLI as:
dotnet add package NotoriousTest
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 : AsyncInfrastructure
{
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 Web Application
Now, let's create a basic web application for our tests.
public class SampleWebApp : WebApplication<Program>
{
// Override WebApplicationFactory methods.
}
โ This is a
WebApplicationFactorycustomized forNotoriousTest.
๐ What this does:
- Defines a minimal web application factory for testing.
Create a Test Environment
A test environment groups infrastructures together.
public class MyTestEnvironment : AsyncWebEnvironment
{
public override async Task ConfigureEnvironmentAsync()
{
AddInfrastructure(new MyInfrastructure()); // Register the test infrastructure
AddWebApplication(new SampleWebApp()); // Register the web app
}
}
๐ What this does:
- Registers MyInfrastructure and SampleWebApp inside the test environment.
- Ensures all tests run in a clean and isolated setup.
Write your first test
Now, let's write a basic integration test using our environment.
public class MyIntegrationTests : AsyncIntegrationTest<MyTestEnvironment>
{
public MyIntegrationTests(MyTestEnvironment environment) : base(environment) { }
[Fact]
public async Task ExampleTest()
{
// Retrieve the infrastructure
var infra = await CurrentEnvironment.GetInfrastructureAsync<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.
Resources & Community
Documentation
- ๐ Core Concepts โ Learn how infrastructures and environments work.
- โก Advanced Features โ Discover ordering, reset behaviors, and more. \
- ๐ Integrations โ See how to integrate SQL Server, TestContainers, and more.
- ๐ Examples โ Hands-on use cases with real-world setups.
Changelog
You can find the changelog here.
Contact
Have questions, ideas, or feedback about NotoriousTests? 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 | net6.0 is compatible. 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 is compatible. 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 is compatible. 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. |
-
net6.0
- Microsoft.AspNetCore.Mvc.Testing (>= 6.0.36)
- xunit (>= 2.5.0)
-
net8.0
- Microsoft.AspNetCore.Mvc.Testing (>= 8.0.20)
- xunit (>= 2.5.0)
-
net9.0
- Microsoft.AspNetCore.Mvc.Testing (>= 9.0.9)
- xunit (>= 2.5.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on NotoriousTest:
| Package | Downloads |
|---|---|
|
NotoriousTest.TestContainers
A TestContainers integration with NotoriousTest. |
|
|
NotoriousTest.PostgreSql
A PostgreSql integration with NotoriousTest. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.1.0 | 183 | 9/13/2025 |
| 3.1.0-beta.41 | 61 | 9/13/2025 |
| 3.1.0-beta.39 | 52 | 9/13/2025 |
| 3.1.0-beta.35 | 64 | 9/12/2025 |
| 3.0.0 | 212 | 9/11/2025 |
| 3.0.0-beta.28 | 86 | 2/22/2025 |
| 2.3.0 | 268 | 2/10/2025 |
| 2.3.0-beta.25 | 72 | 2/22/2025 |
| 2.3.0-beta.23 | 82 | 2/14/2025 |
| 2.3.0-beta.20 | 85 | 2/12/2025 |
| 2.3.0-beta.18 | 83 | 2/10/2025 |
| 2.3.0-beta.16 | 81 | 2/9/2025 |
| 2.3.0-beta.14 | 79 | 2/9/2025 |
| 2.3.0-beta.9 | 84 | 2/9/2025 |
| 2.2.0 | 154 | 2/9/2025 |
| 2.2.0-beta.7 | 76 | 2/9/2025 |
| 2.2.0-beta.5 | 76 | 2/9/2025 |
| 2.2.0-beta.4 | 82 | 2/9/2025 |
| 2.2.0-beta.2 | 77 | 2/9/2025 |
| 2.1.0 | 179 | 2/2/2025 |
| 2.0.0 | 182 | 9/4/2024 |
| 1.3.4 | 204 | 5/5/2024 |
| 1.3.3 | 184 | 5/5/2024 |
| 1.3.2 | 174 | 5/5/2024 |
| 1.2.1 | 209 | 1/17/2024 |
| 1.2.0 | 214 | 10/3/2023 |
| 1.1.0 | 177 | 9/28/2023 |
| 1.0.0 | 191 | 9/19/2023 |