NotoriousTest.TestContainers 4.0.0-beta.65

This is a prerelease version of NotoriousTest.TestContainers.
dotnet add package NotoriousTest.TestContainers --version 4.0.0-beta.65
                    
NuGet\Install-Package NotoriousTest.TestContainers -Version 4.0.0-beta.65
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NotoriousTest.TestContainers" Version="4.0.0-beta.65" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NotoriousTest.TestContainers" Version="4.0.0-beta.65" />
                    
Directory.Packages.props
<PackageReference Include="NotoriousTest.TestContainers" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NotoriousTest.TestContainers --version 4.0.0-beta.65
                    
#r "nuget: NotoriousTest.TestContainers, 4.0.0-beta.65"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NotoriousTest.TestContainers@4.0.0-beta.65
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NotoriousTest.TestContainers&version=4.0.0-beta.65&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=NotoriousTest.TestContainers&version=4.0.0-beta.65&prerelease
                    
Install as a Cake Tool

Clean, isolated, and maintainable integration testing for .NET

NuGet NuGet Downloads License .NET Build Status GitHub stars

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.

NotoriousTests removes the need to build all of that yourself.

The concept is simple:

  1. Create an infrastructure and implement its initialization, reset, and destruction logic.
  2. Add it to an environment.
  3. Access it directly from your integration tests.

NotoriousTests will automatically manage the lifecycle of your infrastructures.

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 WebApplicationFactory customized for NotoriousTest.

📌 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:

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 Compatible and additional computed target framework versions.
.NET 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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.0-beta.65 43 3/23/2026
4.0.0-beta.61 38 3/23/2026
4.0.0-beta.58 35 3/22/2026
4.0.0-beta.54 40 3/15/2026
4.0.0-beta.52 40 3/14/2026
4.0.0-beta.49 39 3/14/2026
3.1.0 181 9/13/2025
3.1.0-beta.47 44 3/14/2026
3.1.0-beta.42 38 3/3/2026
3.1.0-beta.41 60 9/13/2025
3.0.0 209 9/11/2025
3.0.0-beta.39 60 9/13/2025
3.0.0-beta.35 62 9/12/2025
3.0.0-beta.28 97 2/22/2025
2.3.0 224 2/10/2025
2.3.0-beta.25 79 2/22/2025
2.3.0-beta.23 91 2/14/2025
2.3.0-beta.20 93 2/12/2025
2.3.0-beta.18 91 2/10/2025
2.3.0-beta.16 92 2/9/2025
Loading failed