In my case I was doing integration tests which involved provisioning and destroying CosmosDB databases and collections. Obviously if one thread destroys the database while another is relying on it, then tests will fail.
So here is how to force xunit to run in a single thread:
1. Create a file in the root of your Visual Studio project named: xunit.runner.json
2. Ensure it's properties are set to "Copy to output directory".
3. Add the following:
{
"parallelizeTestCollections": false,
"maxParallelThreads": 1
}
4. Now build your project, and run: dotnet test
Dang Easy!
More info here: https://xunit.github.io/docs/configuring-with-json.html
No comments:
Post a Comment