ManagedCode.ManagedCode.IntegrationTestBaseKit
0.0.2
Prefix Reserved
dotnet add package ManagedCode.ManagedCode.IntegrationTestBaseKit --version 0.0.2
NuGet\Install-Package ManagedCode.ManagedCode.IntegrationTestBaseKit -Version 0.0.2
<PackageReference Include="ManagedCode.ManagedCode.IntegrationTestBaseKit" Version="0.0.2" />
paket add ManagedCode.ManagedCode.IntegrationTestBaseKit --version 0.0.2
#r "nuget: ManagedCode.ManagedCode.IntegrationTestBaseKit, 0.0.2"
// Install ManagedCode.ManagedCode.IntegrationTestBaseKit as a Cake Addin #addin nuget:?package=ManagedCode.ManagedCode.IntegrationTestBaseKit&version=0.0.2 // Install ManagedCode.ManagedCode.IntegrationTestBaseKit as a Cake Tool #tool nuget:?package=ManagedCode.ManagedCode.IntegrationTestBaseKit&version=0.0.2
IntegrationTestBaseKit
Overview
IntegrationTestBaseKit is a library designed to facilitate the creation and management of Docker containers for integration testing purposes. It provides a set of tools to start, stop, and check the readiness of Docker containers in a thread-safe manner.
Features
- Start and stop Docker containers asynchronously.
- Check container readiness using customizable wait strategies.
- Event-driven notifications for container lifecycle events (starting, started, stopping, stopped).
Installation
To install the library, use the following command:
dotnet add package ManagedCode.IntegrationTestBaseKit
for xUnit integration use the following command:
dotnet add package ManagedCode.ManagedCode.IntegrationTestBaseKit.XUnit
Usage
Creating a Test Application
Define a TestApp class that inherits from BaseXUnitTestApp<TestBlazorApp.Program>
, add ICollectionFixture<TestApp>
using DotNet.Testcontainers.Containers;
using Testcontainers.Azurite;
using Testcontainers.PostgreSql;
using Xunit;
namespace ManagedCode.IntegrationTestBaseKit.Tests
{
[CollectionDefinition(nameof(TestApp))]
public class TestApp : BaseXUnitTestApp<TestBlazorApp.Program>, ICollectionFixture<TestApp>
{
protected override async Task ConfigureTestContainers()
{
AddContainer(new AzuriteBuilder().Build());
AddContainer("postgree", new PostgreSqlBuilder().Build());
}
}
}
Writing Tests
Use the TestApp class in your tests to manage Docker containers.
using DotNet.Testcontainers.Containers;
using FluentAssertions;
using Testcontainers.Azurite;
using Testcontainers.PostgreSql;
using Xunit.Abstractions;
namespace ManagedCode.IntegrationTestBaseKit.Tests;
[Collection(nameof(TestApp))]
public class HealthTests(ITestOutputHelper log, TestApp testApplication)
{
[Fact]
public async Task HealthTest()
{
var client = testApplication.CreateHttpClient();
var response = await client.GetAsync("/health");
response.EnsureSuccessStatusCode();
}
[Fact]
public async Task BrowserHealthTest()
{
var page = await testApplication.OpenNewPage("/health");
var content = await page.ContentAsync();
content.Contains("Healthy")
.Should()
.BeTrue();
}
[Fact]
public async Task HealthTest()
{
var client = testApplication.CreateSignalRClient("/healthHub");
await client.StartAsync();
client.State
.Should()
.Be(HubConnectionState.Connected);
var result = await client.InvokeAsync<string>("Health");
result.Should()
.Be("Healthy");
}
}
Product | Versions 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. |
-
net8.0
- Microsoft.AspNetCore.Mvc.Testing (>= 8.0.8)
- Microsoft.AspNetCore.SignalR.Client (>= 8.0.8)
- Microsoft.NET.Test.Sdk (>= 17.11.0)
- Microsoft.Playwright (>= 1.46.0)
- Microsoft.TestPlatform.TestHost (>= 17.11.0)
- Testcontainers (>= 3.9.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ManagedCode.ManagedCode.IntegrationTestBaseKit:
Package | Downloads |
---|---|
ManagedCode.IntegrationTestBaseKit.XUnit
Extensions for ASP.NET for managing Docker containers in integration tests. |
GitHub repositories
This package is not used by any popular GitHub repositories.