Tennisi.Xunit.ParallelTestFramework.UI
6.2.321
dotnet add package Tennisi.Xunit.ParallelTestFramework.UI --version 6.2.321
NuGet\Install-Package Tennisi.Xunit.ParallelTestFramework.UI -Version 6.2.321
<PackageReference Include="Tennisi.Xunit.ParallelTestFramework.UI" Version="6.2.321" />
<PackageVersion Include="Tennisi.Xunit.ParallelTestFramework.UI" Version="6.2.321" />
<PackageReference Include="Tennisi.Xunit.ParallelTestFramework.UI" />
paket add Tennisi.Xunit.ParallelTestFramework.UI --version 6.2.321
#r "nuget: Tennisi.Xunit.ParallelTestFramework.UI, 6.2.321"
#:package Tennisi.Xunit.ParallelTestFramework.UI@6.2.321
#addin nuget:?package=Tennisi.Xunit.ParallelTestFramework.UI&version=6.2.321
#tool nuget:?package=Tennisi.Xunit.ParallelTestFramework.UI&version=6.2.321
Tennisi.Xunit.ParallelTestFramework assembly
Tennisi.Xunit namespace
public type | description |
---|---|
class DisableParallelizationAttribute | Attribute that disables parallel test execution for a class, overriding any higher-level settings that enable parallelization. |
class DisableTestParallelizationAttribute | Assembly-level attribute that disables xunit.discovery.PreEnumerateTheories , xunit.parallelizeTestCollections , xunit.parallelizeAssembly and enables xunit.execution.DisableParallelization in the xUnit framework. Alternatively, the DisbaleTestParallelization property can be set in the project file to achieve the same effect. |
class EnableParallelizationAttribute | Attribute that enables parallel test execution for a class, overriding any higher-level settings that disable parallelization. |
class FullTestParallelizationAttribute | An assembly-level attribute that enables parallelizeTestCollections and preEnumerateTheories in the xUnit framework. Alternatively, you can set the FullTestParallelization property in your project file. |
struct ParallelTag | A readonly structure that serves as a Xunit fixture to provide unique but constant value for test fact or theory version, facilitating parallel execution of tests while ensuring consistency in tagging. |
class RetryClassAttribute | Represents a custom xUnit attribute to specify that all test methods in the class (both facts and theories) should be retried a specified number of times. |
class RetryFactAttribute | Represents a custom xUnit attribute to retry a test a specified number of times. |
class RetryTheoryAttribute | Represents a custom xUnit attribute to retry a theory test a specified number of times. |
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 Tennisi.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
Parallel in a collection
Using the EnableParallelizationAttribute
on an ICollectionFixture<T>
enables the parallel execution between classes in a collection.
If you want to enable parallisation inside a class you still need to add the EnableParallelizationAttribute
on the test class aswell.
[CollectionDefinition("MyFixture Collection")]
[EnableParallelization] // This enables the parallel execution of classes in a collection
public class MyFixtureCollection : ICollectionFixture<MyFixture>
{
}
[Collection("MyFixture Collection")]
public class MyFirstTestClass
{
private readonly MyFixture fixture;
public ParallelCollectionMultiClass1AttributeTests(MyFixture fixture)
{
this.fixture = fixture;
}
//...
}
[Collection("MyFixture Collection")]
public class MySecondTestClass
{
private readonly MyFixture fixture;
public ParallelCollectionMultiClass1AttributeTests(MyFixture fixture)
{
this.fixture = fixture;
}
//...
}
Achieving Maximum Productivity
Use the FullTestParallelizationAttribute
on an assembly and inject ParallelTag
into the constructor of each of your tests.
public class MyTests
{
private readonly int _betId;
public MyTests(ITestOutputHelper helper, ParallelTag tag = new())
{
_betId = tag.AsLong();
}
[Fact]
public void Do()
{
}
}
This strategy will allow you to run each Fact or Theory variant in parallel. Each time xUnit starts your test, a new unique but constant ParallelTag will be injected into your test class, allowing your test to work with unique data without interfering with other tests.
WinForms/WPF Applications
STA model apps should use the Tennisi.Xunit.ParallelTestFramework.UI
package.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0-windows7.0 is compatible. net8.0-windows was computed. net8.0-windows7.0 is compatible. net9.0-windows was computed. net10.0-windows was computed. |
-
net7.0-windows7.0
- xunit.extensibility.execution (>= 2.9.2)
-
net8.0-windows7.0
- xunit.extensibility.execution (>= 2.9.2)
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 |
---|---|---|
6.2.321 | 108 | 12/27/2024 |
6.2.320 | 103 | 12/27/2024 |
6.2.319 | 100 | 12/27/2024 |
6.2.318 | 102 | 12/27/2024 |
6.2.311 | 103 | 12/27/2024 |
6.2.266 | 107 | 12/23/2024 |
6.2.265 | 103 | 12/23/2024 |
6.2.264 | 101 | 12/23/2024 |
6.2.263 | 100 | 12/23/2024 |
6.2.262 | 101 | 12/23/2024 |
6.2.260 | 110 | 12/23/2024 |
6.2.259 | 104 | 12/23/2024 |
6.2.258 | 101 | 12/23/2024 |
6.2.257 | 99 | 12/23/2024 |
6.2.256 | 100 | 12/23/2024 |
6.2.255 | 106 | 12/23/2024 |
6.2.254 | 101 | 12/23/2024 |
6.2.253 | 102 | 12/23/2024 |
6.2.252 | 101 | 12/23/2024 |
6.2.251 | 91 | 12/23/2024 |
6.2.250 | 93 | 12/23/2024 |
6.2.249 | 89 | 12/23/2024 |
6.2.248 | 97 | 12/23/2024 |
6.2.247 | 98 | 12/23/2024 |
6.2.245 | 96 | 12/22/2024 |
6.2.244 | 95 | 12/22/2024 |
6.2.243 | 99 | 12/22/2024 |
6.2.242 | 93 | 12/22/2024 |
6.2.241 | 88 | 12/22/2024 |
6.2.240 | 92 | 12/22/2024 |
6.2.239 | 92 | 12/22/2024 |
6.2.238 | 97 | 12/22/2024 |
6.2.237 | 103 | 12/22/2024 |
6.2.236 | 100 | 12/22/2024 |
6.2.233 | 94 | 12/22/2024 |
6.0.1 | 104 | 12/27/2024 |
4.2.316 | 87 | 12/22/2024 |
4.2.308 | 97 | 12/22/2024 |
4.2.307 | 89 | 12/22/2024 |
4.2.305 | 94 | 12/22/2024 |
1.0.0-preview.11 | 60 | 1/29/2025 |
1.0.0-preview.10 | 54 | 1/29/2025 |
1.0.0-preview.9 | 54 | 1/29/2025 |
1.0.0-preview.8 | 55 | 1/29/2025 |
1.0.0-preview.6 | 57 | 1/29/2025 |
1.0.0-preview.4 | 62 | 1/29/2025 |
1.0.0-preview.3 | 59 | 1/29/2025 |
1.0.0-preview.2 | 59 | 1/29/2025 |
1.0.0-preview.0 | 58 | 1/29/2025 |
0.0.1 | 104 | 12/26/2024 |
0.0.0-alpha.0 | 64 | 1/29/2025 |