XUnit.Extensions.MaxParallelization
1.0.12
See the version list below for details.
dotnet add package XUnit.Extensions.MaxParallelization --version 1.0.12
NuGet\Install-Package XUnit.Extensions.MaxParallelization -Version 1.0.12
<PackageReference Include="XUnit.Extensions.MaxParallelization" Version="1.0.12" />
paket add XUnit.Extensions.MaxParallelization --version 1.0.12
#r "nuget: XUnit.Extensions.MaxParallelization, 1.0.12"
// Install XUnit.Extensions.MaxParallelization as a Cake Addin #addin nuget:?package=XUnit.Extensions.MaxParallelization&version=1.0.12 // Install XUnit.Extensions.MaxParallelization as a Cake Tool #tool nuget:?package=XUnit.Extensions.MaxParallelization&version=1.0.12
XUnit.Extensions.MaxParallelization
This library is there to run every test cases in parallel by default. It also changes how Fixture are injected in XUnit.
Setup
Install the nuget package:
NuGet\Install-Package XUnit.Extensions.MaxParallelization
Then you need to add the following assembly attribute:
[assembly: TestFramework("XUnit.Extensions.MaxParallelization.ParallelTestFramework", "XUnit.Extensions.MaxParallelization")]
Parallelization
With this library every test cases, classes and collections will run in parallel. Therefore if you don't want a test case, a class or a collection to run in parallel you will need to set the DisableParallelization
attribute over the class or the test method on which you do not want to run in parallel.
For collections you need to set it inside the CollectionDefinition
attribute like so:
[CollectionDefinition("DisableParallelization",DisableParallelization = true)]
Fixture Injection
This extension change the way dependency injection is handled in XUnit. I wanted to make this more like it is handled in ASP.Net.
public class FixtureRegister : IFixtureRegister
{
public void RegisterFixtures(FixtureRegistrationCollection container)
{
container.AddFixture<OrderingFixture>()
.AddFixture<CollectionParallelTestFixture>(FixtureRegisterationLevel.Collection)
.AddFixture<AssemblyParallelTestFixture>(FixtureRegisterationLevel.Assembly)
.AddFixture<ClassParallelTestFixture>(FixtureRegisterationLevel.Class)
.AddFixture<MethodParallelTestFixture>(FixtureRegisterationLevel.Method);
}
}
The FixtureRegisterationLevel
parameter is there to declare the scope of the dependency.
Assembly
will create a singleton for the whole assembly
Collection
create an instance that will be shared among all the tests cases in the same collections
Class
create an instance that will be shared among tests cases in the same class
Method
Create an instance for each test case.
You can pass an instance as a parameter but unless the scope is assembly the dependency will be reinstanciated at some point.
This code is greatly inspired by this repository from Gérald Barré.
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 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. |
-
net6.0
- xunit.extensibility.execution (>= 2.4.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.