Skip to content

testconfig.json with comments is silently ignored #10584

Description

Describe the bug

If I have a testconfig.json, it is automatically consumed.

If it is malformed JSON, it (correctly) fails the build.

If the JSON includes comments, it is silently ignored.

Version used

dotnet 10.0.302
Microsoft.Testing.Extensions.CodeCoverage 18.10.0

Steps To Reproduce

dotnet new install xunit.v3.templates
dotnet new xunit3
dotnet add package Microsoft.Testing.Extensions.CodeCoverage

Add a testconfig.json with:

{
  "codeCoverage": {
    "Configuration": {
      "IncludeTestAssembly": true // this is a comment
    }
  }
}

Then run:

dotnet run -- --coverage --coverage-output-format cobertura

Expected behavior

Either the build should fail (because comments are not allowed), or the config should
be respected (preferred).

Actual behavior

The project runs the tests successfully, but the generated coverage file does not contain the test project.

Note, if you remove the comment, then the coverage of the test project is included.

Additional context

I originally found this using TUnit, but I reproduced here using xUnit.

testconfig_bug.zip

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions