Search code examples
.net-corexunit

Ignore xunit.runner.json on local


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?


Solution

  • 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>