Meziantou.Xunit.ParallelTestFramework
2.1.0
dotnet add package Meziantou.Xunit.ParallelTestFramework --version 2.1.0
NuGet\Install-Package Meziantou.Xunit.ParallelTestFramework -Version 2.1.0
<PackageReference Include="Meziantou.Xunit.ParallelTestFramework" Version="2.1.0" />
paket add Meziantou.Xunit.ParallelTestFramework --version 2.1.0
#r "nuget: Meziantou.Xunit.ParallelTestFramework, 2.1.0"
// Install Meziantou.Xunit.ParallelTestFramework as a Cake Addin
#addin nuget:?package=Meziantou.Xunit.ParallelTestFramework&version=2.1.0
// Install Meziantou.Xunit.ParallelTestFramework as a Cake Tool
#tool nuget:?package=Meziantou.Xunit.ParallelTestFramework&version=2.1.0
By default, xUnit runs all test cases in a test class synchronously. This package extends the default test framework to execute tests in parallel.
dotnet add package Meziantou.Xunit.ParallelTestFramework
By default, all tests will run in parallel.
Selectively disable parallelization by adding the DisableParallelization
attribute to a collection or theory.
// All tests are run in parallel
public class ParallelTests
{
[Fact]
public void Test1() => Thread.Sleep(2000);
[Fact]
public void Test2() => Thread.Sleep(2000);
[Theory]
[InlineData(0), InlineData(1), InlineData(2)]
public void Test3(int value) => Thread.Sleep(2000);
// This test runs in parallel with other tests
// However, its test cases are run sequentially
[Theory]
[DisableParallelization]
[InlineData(0), InlineData(1), InlineData(2)]
public void Test4(int value) => Thread.Sleep(2000);
}
// This collection runs in parallel with other collections
// However, its tests cases are run sequentially
[DisableParallelization]
public class SequentialTests
{
[Fact]
public void Test1() => Thread.Sleep(2000);
[Fact]
public void Test2() => Thread.Sleep(2000);
}
Previous versions of this package relied on built in xUnit attributes instead of exposing a dedicated DisableParallelization
attribute.
For backwards compatibility, parallelization can also be disabled by adding an explicit Collection
attribute or Theory
attribute with DisableDiscoveryEnumeration
enabled.
// All tests are run in parallel
public class ParallelTests
{
[Fact]
public void Test1() => Thread.Sleep(2000);
[Fact]
public void Test2() => Thread.Sleep(2000);
[Theory]
[InlineData(0), InlineData(1), InlineData(2)]
public void Test3(int value) => Thread.Sleep(2000);
// This test runs in parallel with other tests
// However, its test cases are run sequentially because of DisableDiscoveryEnumeration
[Theory]
[MemberData(nameof(GetData), DisableDiscoveryEnumeration = true)]
public void Test4(int value) => Thread.Sleep(2000);
public static TheoryData<int> GetData() => new() { { 0 }, { 1 } };
}
// This collection runs in parallel with other collections
// However, its tests cases are run sequentially because the Collection is explicit
[Collection("Sequential")]
public class SequentialTests
{
[Fact]
public void Test1() => Thread.Sleep(2000);
[Fact]
public void Test2() => Thread.Sleep(2000);
}
The code is greatly inspired by the sample from Travis Mortimer: https://github.com/xunit/xunit/issues/1986#issuecomment-831322722
Product | Versions |
---|---|
.NET | net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows |
.NET Core | netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1 |
.NET Standard | netstandard2.0 netstandard2.1 |
.NET Framework | net461 net462 net463 net47 net471 net472 net48 net481 |
MonoAndroid | monoandroid |
MonoMac | monomac |
MonoTouch | monotouch |
Tizen | tizen40 tizen60 |
Xamarin.iOS | xamarinios |
Xamarin.Mac | xamarinmac |
Xamarin.TVOS | xamarintvos |
Xamarin.WatchOS | xamarinwatchos |
-
.NETStandard 2.0
- xunit.extensibility.execution (>= 2.4.2)
-
net6.0
- xunit.extensibility.execution (>= 2.4.2)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Meziantou.Xunit.ParallelTestFramework:
Package | Downloads |
---|---|
FunFair.Test.Common
FunFair Common Test Infrastructure for building xUnit tests on top of. |
|
BunsenBurner.Xunit
Integration with [xUnit.net](https://github.com/xunit/xunit) to easily consume Bunsen Burner |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on Meziantou.Xunit.ParallelTestFramework:
Repository | Stars |
---|---|
riok/mapperly
A .NET source generator for generating object mappings. No runtime reflection. Inspired by MapStruct.
|
|
meziantou/Meziantou.Framework
|