简体   繁体   中英

No parallel tests with 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?

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
}

图片

With:

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

图片

For those who are trying to disable parallelism in their .net core (>= 2.1) projects:

Create xunit.runner.json and write below:

{
  "parallelizeAssembly": false,
  "parallelizeTestCollections": false
}

Add to csproj:

  <ItemGroup>
    <None Update="xunit.runner.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
  </ItemGroup>

Cheers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM