Microcks.Testcontainers 0.1.0

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Microcks.Testcontainers --version 0.1.0
                    
NuGet\Install-Package Microcks.Testcontainers -Version 0.1.0
                    
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="Microcks.Testcontainers" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Microcks.Testcontainers" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Microcks.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 Microcks.Testcontainers --version 0.1.0
                    
#r "nuget: Microcks.Testcontainers, 0.1.0"
                    
#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 Microcks.Testcontainers@0.1.0
                    
#: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=Microcks.Testcontainers&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Microcks.Testcontainers&version=0.1.0
                    
Install as a Cake Tool

Microcks Testcontainers .NET

.NET library for Testcontainers that enables embedding Microcks into your unit tests with lightweight, throwaway instance thanks to containers.

GitHub Workflow Status Version License Project Chat Artifact HUB CNCF Landscape

Build Status

Latest released version is 0.1.0.

Current development version is 0.2.0.

Sonarcloud Quality metrics

Code Smells Reliability Rating Bugs Coverage Technical Debt Security Rating Maintainability Rating

Fossa license and security scans

FOSSA Status FOSSA Status FOSSA Status

OpenSSF best practices on Microcks core

CII Best Practices OpenSSF Scorecard

Community

To get involved with our community, please make sure you are familiar with the project's Code of Conduct.

How to use it?

Include it into your project dependencies

dotnet add package Microcks.Testcontainers --version 0.1.0

Startup the container

You just have to specify the container image you'd like to use. This library requires a Microcks uber distribution (with no MongoDB dependency).

MicrocksContainer container = new MicrocksBuilder()
	.WithImage("quay.io/microcks/microcks-uber:1.10.0")
	.Build();
await container.StartAsync();

Import content in Microcks

To use Microcks mocks or contract-testing features, you first need to import OpenAPI, Postman Collection, GraphQL or gRPC artifacts. Artifacts can be imported as main/Primary ones or as secondary ones. See Multi-artifacts support for details.

You can do it before starting the container using simple paths:

MicrocksContainer container = new MicrocksBuilder()
	  .WithMainArtifacts("apipastries-openapi.yaml")
	  .WithSecondaryArtifacts("apipastries-postman-collection.json")
	  .Build();
await container.StartAsync();

or once the container started using File arguments:

container.ImportAsMainArtifact("apipastries-openapi.yaml");
container.ImportAsSecondaryArtifact("apipastries-postman-collection.json");

You can also import full repository snapshots at once:

MicrocksContainer container = new MicrocksBuilder()
      .WithSnapshots("microcks-repository.json")
	  .Build();
await container.StartAsync();

Using mock endpoints for your dependencies

During your test setup, you'd probably need to retrieve mock endpoints provided by Microcks containers to setup your base API url calls. You can do it like this:

var baseApiUrl = container.GetRestMockEndpoint("API Pastries", "0.0.1");

The container provides methods for different supported API styles/protocols (Soap, GraphQL, gRPC,...).

The container also provides GetHttpEndpoint() for raw access to those API endpoints.

Launching new contract-tests

If you want to ensure that your application under test is conformant to an OpenAPI contract (or other type of contract), you can launch a Microcks contract/conformance test using the local server port you're actually running.

private int port;

public async Task InitializeAsync()
{
	container = new MicrocksBuilder()
		.WithExposedPort(port)
		.Build();
	await container.StartAsync();
}

[Fact]
public async Task testOpenAPIContract()
{
	var testRequest = new TestRequest
	{
		ServiceId = "API Pastries:0.0.1",
		RunnerType = TestRunnerType.OPEN_API_SCHEMA,
		TestEndpoint = $"http://host.testcontainers.internal:{port}",
		Timeout = TimeSpan.FromMilliseconds(2000)
	};
	TestResult testResult = await container.TestEndpointAsync(testRequest);

	testResult.Success.Should().BeTrue();
}

The TestResult gives you access to all details regarding success of failure on different test cases.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  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 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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.30.0-alpha.97 251 2/4/2025
0.3.1-alpha.245 180 8/24/2025
0.3.1-alpha.221 370 7/21/2025
0.3.1-alpha.209 77 6/27/2025
0.3.1-alpha.206 76 6/27/2025
0.3.0 163 6/27/2025
0.3.0-alpha.201 100 6/27/2025
0.3.0-alpha.199 123 6/25/2025
0.3.0-alpha.196 122 6/23/2025
0.3.0-alpha.195 124 6/17/2025
0.3.0-alpha.190 224 5/15/2025
0.3.0-alpha.187 211 5/15/2025
0.3.0-alpha.186 212 5/14/2025
0.3.0-alpha.172 216 5/13/2025
0.3.0-alpha.164 93 5/2/2025
0.3.0-alpha.158 137 4/29/2025
0.3.0-alpha.143 145 4/6/2025
0.3.0-alpha.140 137 3/31/2025
0.3.0-alpha.124 160 3/11/2025
0.2.0 896 2/4/2025
0.2.0-alpha.95 87 2/3/2025
0.2.0-alpha.83 74 1/28/2025
0.2.0-alpha.80 77 1/28/2025
0.2.0-alpha.77 72 1/23/2025
0.2.0-alpha.73 69 1/15/2025
0.2.0-alpha.72 66 1/15/2025
0.2.0-alpha.68 78 1/10/2025
0.2.0-alpha.21 80 11/21/2024
0.1.0 152 11/21/2024
0.1.0-alpha.19 90 11/21/2024
0.1.0-alpha.18 70 11/21/2024
0.1.0-alpha.16 71 11/21/2024
0.1.0-alpha.15 68 11/20/2024
0.1.0-alpha.12 66 11/20/2024
0.1.0-alpha.11 72 11/20/2024
0.1.0-alpha.1 73 11/20/2024