Ignore xunit.runner.json on local

Viewed 85

I am using xunit as a testframework for a .netcore 3.1 project. When running tests locally, I would prefer having different settings, like "parallelizeAssembly": true, whereas it is usually set to false.

Is it somehow possible to set different xunit.runner.json files for different environments or somehow ignore the file on certain circumstances?

2 Answers

you can try to use conditional project settings like if you want to include xunit.runner.json only in debug mode then you can modify your project file lile this.

<ItemGroup Condition="'$(Configuration)' == 'Debug'">
  <Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

or if you want to have different file in different configuration then you can also do like this

for debug mode.

<ItemGroup Condition="'$(Configuration)' == 'Debug'">
      <Content Include="xunit.runner.debug.json" CopyToOutputDirectory="PreserveNewest" />
  </ItemGroup>

for release

<ItemGroup Condition="'$(Configuration)' == 'Release'">
          <Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
      </ItemGroup>

You must use configuration files instead.

xunit.runner.json:

{
    "parallelizeAssembly": true
}

parallelizeAssembly defaults to false

Set this to true if this assembly is willing to participate in parallelization with other assemblies.

parallelizeTestCollections defaults to true

Set this to true if the assembly is willing to run tests inside this assembly in parallel against each other. Tests in the same test collection will be run sequentially against each other

Related