Mittons.Fixtures
1.0.0-rc.1
See the version list below for details.
dotnet add package Mittons.Fixtures --version 1.0.0-rc.1
NuGet\Install-Package Mittons.Fixtures -Version 1.0.0-rc.1
<PackageReference Include="Mittons.Fixtures" Version="1.0.0-rc.1" />
paket add Mittons.Fixtures --version 1.0.0-rc.1
#r "nuget: Mittons.Fixtures, 1.0.0-rc.1"
// Install Mittons.Fixtures as a Cake Addin #addin nuget:?package=Mittons.Fixtures&version=1.0.0-rc.1&prerelease // Install Mittons.Fixtures as a Cake Tool #tool nuget:?package=Mittons.Fixtures&version=1.0.0-rc.1&prerelease
Mittons.Fixtures
Mittons.Fixtures is a framework for standing up testing environments via fixtures, which can be integrated into other testing frameworks.
Introduction
This project was created to allow developers to declare their environments in a fixture using attributes to define service settings, allowing the testing framework to spin up the full environment. This saves developers the need to create pre/post test scripts that build/teardown the testing environment, and keeps the environment definition closer to the actual tests.
Documentation
Currently, this library uses Docker for spinning up the test environment. To define an environment, you would create a class extending the DockerEnvironmentFixture, and define all the containers you wish to stand up. When you define a fixture, the following attributes can be applied:
- [Run(string)] - Defines the details for the run, this currently only accepts a string representing an environment variable from which to get an id to apply to all resources created in the test environment. This allows you to use that identifier for post-test cleanup action in the instance the tests are cancelled prematurely and normal cleanup behavior does not occur.
- [Network(string)] - Defines a Docker network to create.
Supported container types are:
- Container: This is the base class for all containers, so if an abstraction for your container type doesn't exist, this is where you would start. All containers support
the following attributes:
- [Image(string)] - Defines the image used to create the container.
- [Command(string)] - Defines the command Docker runs once the container is started.
- [HealthCheck(Disabled = boolean, Command = string, Interval = TimeSpan, Timeout = TimeSpan, StartPeriod = TimeSpan, Retries = int)] - Defines the settings for Docker to perform health checks on the container.
- [NetworkAlias(string, string)] - Defines a Docker network to which the container should be attached, and the alias by which other containers on the network can communicate with it.
- SftpContainer: Extending Container, this adds extra convenience functionality specific to spinning up and Sftp server. SftpContainers are built using the
atmoz/sftp:alpine image, and since that assumes certain behaviors, [Image] attributes will be ignored for these containers. In addtion
to the normal Container attributes, SftpContainer supports the following attributes:
- [SftpUserAccout(string, string)] - Adds an account to the sftp server using the provided username and password.
A good reference on how do define an environment can be found in the Mittons.Fixtures.Example project, which is designed to demo this library.
Example
Note: This example leverages the SSH.NET library
public class ReportingEnvironmentFixture : DockerEnvironmentFixture
{
[SftpUserAccount("admin", "securepassword")]
[SftpUserAccount("tswift", "hatersgonnahate")]
public SftpContainer SftpContainer { get; set; }
}
public class ConnectionSettingsTests : IClassFixture<ReportingEnvironmentFixture>
{
private readonly ReportingEnvironmentFixture _reportingEnvironment;
public ConnectionSettingsTests(ReportingEnvironmentFixture reportingEnvironment)
{
_reportingEnvironment = reportingEnvironment;
}
[Fact]
public void Connect_WhenUsingTheAdminCredentials_ExpectASuccessfulConnection()
{
// Arrange
var connectionSettings = _reportingEnvironment.SftpContainer.SftpConnectionSettings.Single(x => x.Key == "admin").Value;
var connectionInfo = new ConnectionInfo(
connectionSettings.Host,
connectionSettings.Port,
connectionSettings.Username,
new PasswordAuthenticationMethod(connectionSettings.Username, connectionSettings.Password)
);
// Act
using var client = new SftpClient(connectionInfo);
client.Connect();
// Assert
Assert.True(client.IsConnected);
}
}
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. |
.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 was computed. |
.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. |
-
.NETStandard 2.0
- xunit.core (>= 2.4.1)
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 |
---|---|---|
1.0.0-rc.4 | 153 | 5/8/2022 |
1.0.0-rc.3 | 139 | 4/17/2022 |
1.0.0-rc.2 | 136 | 4/16/2022 |
1.0.0-rc.1 | 133 | 4/9/2022 |
1.0.0-prerelease.3 | 128 | 4/9/2022 |
1.0.0-prerelease.2 | 126 | 4/7/2022 |
1.0.0-prerelease | 129 | 4/6/2022 |