C#C
C#3mo ago
2 replies
Core

✅ Xunit v3 running test cases in parallel

Hello, tests are running in parallel, but not test cases.

One of my tests has to process more than 50 fixture files, and it currently runs synchronously. How can I make it run in parallel?
[Theory]
[MemberData(nameof(FixtureFileNames))]
public async Task TryParse_ShouldProduceConsistentResultsAcrossParsers(string fileName)
{
    var fixturePath = Path.Combine("Fixtures", "Collections", $"{fileName}.json");
    var fixtures = await FixtureLoader.LoadAsync<UserAgentFixture>(fixturePath);

    // assertion
}

public static TheoryData<string> FixtureFileNames =>
[
    "cameras",
    "car_browsers",
    "client_hints",
    "client_hints_apps",
    "consoles",
    "desktops",
    "desktops_1",
    "feature_phones",
    "feed_readers",
    "media_players",
]


xunit.runner.json is also loaded
{
  "$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
  "parallelizeAssembly": true,
  "parallelizeTestCollections": true,
  "maxParallelThreads": "unlimited"
}
Was this page helpful?