XUnit.Extensions.MaxParallelization 1.0.9

There is a newer version of this package available.
See the version list below for details.
dotnet add package XUnit.Extensions.MaxParallelization --version 1.0.9                
NuGet\Install-Package XUnit.Extensions.MaxParallelization -Version 1.0.9                
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="XUnit.Extensions.MaxParallelization" Version="1.0.9" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add XUnit.Extensions.MaxParallelization --version 1.0.9                
#r "nuget: XUnit.Extensions.MaxParallelization, 1.0.9"                
#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.
// Install XUnit.Extensions.MaxParallelization as a Cake Addin
#addin nuget:?package=XUnit.Extensions.MaxParallelization&version=1.0.9

// Install XUnit.Extensions.MaxParallelization as a Cake Tool
#tool nuget:?package=XUnit.Extensions.MaxParallelization&version=1.0.9                

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 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. 
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
1.0.15 355 3/25/2023
1.0.14 230 3/22/2023
1.0.13 220 3/22/2023
1.0.12 229 3/22/2023
1.0.11 272 2/3/2023
1.0.9 313 1/9/2023
1.0.8 316 1/6/2023
1.0.4 311 1/6/2023
1.0.0 306 12/25/2022