Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No parallel tests with xUnit DNX

Tags:

json

c#

xunit

dnx

I'm trying execute my tests one by one, without parallel.

I tried to configure that on my xunit.runner.json file, but without success:

{
  "maxParallelThreads": 1,
  "parallelizeAssembly": false,
  "parallelizeTestCollections": false,
  "preEnumerateTheories": false
}

What am I doing wrong?

like image 607
Cesar Avatar asked Nov 09 '15 19:11

Cesar


People also ask

Does xUnit run tests in parallel?

In our case, the strategy is to reassign all test cases to a new collection, and then let xUnit execute the tests. As all tests are in a different collection, xUnit will execute them in parallel. That is that simple!

How do I ignore tests in xUnit?

xUnit.net does not require an attribute for a test class; it looks for all test methods in all public (exported) classes in the assembly. Set the Skip parameter on the [Fact] attribute to temporarily skip a test.

Does dotnet test run in parallel?

Luckily, dotnet test using xUnit V2 runs the tests inside of a project (or even inside a solution) in parallel by default. So at least the tests inside of a project will be started in parallel.

What is xUnit runner JSON?

xunit. runner. json (where <AssemblyName> is the name of your unit test assembly, without the file extension like . dll or .exe ). You should only need to use this longer name format if your unit tests DLLs will all be placed into the same output folder, and you need to disambiguate the various configuration files.


1 Answers

I'm on dnx 1.0.0-rc1-final, xunit 2.1.0, xunit.runner.dnx 2.1.0-rc1-build204, and the maxParallelThreads setting in xunit.runner.json is working for me from the command line.

Do you have your tests separated by collections? According to the docs:

By default, each test class is a unique test collection.

So given some contrived "tests" like these, it should be easy to see if they run in parallel or not:

With:

{
    "diagnosticMessages": true,
    "maxParallelThreads":  4
}

image

With:

{
    "diagnosticMessages": true,
    "maxParallelThreads":  1
}

image

like image 193
Stajs Avatar answered Nov 03 '22 00:11

Stajs