Meziantou.Xunit.ParallelTestFramework
Meziantou.Xunit.ParallelTestFramework copied to clipboard
Parallel tests execution in a collection
I have a very common case of testing. I have a collection fixture:
[CollectionDefinition(nameof(SomeCollection))]
public class SomeCollection : ICollectionFixture<ImmutableClass>
{
}
with some test classes:
[Collection(nameof(SomeCollection))]
public class TestClass1
{
[Fact]
public async Task Test1() => await Task.Delay(3000);
[Fact]
public async Task Test2() => await Task.Delay(3000);
}
[Collection(nameof(SomeCollection))]
public class TestClass2
{
[Fact]
public async Task Test3() => await Task.Delay(3000);
[Fact]
public async Task Test4() => await Task.Delay(3000);
}
This fixture is immutable, so I want to run each test method in the collection parallel. It should be 4 times faster. Is there any way to achieve this?