Skip to content

Parameterize CodeCoverage test on IncludeTestAssembly (#52029)#54514

Open
Evangelink wants to merge 1 commit into
dotnet:mainfrom
Evangelink:dev/amauryleve/fix-52029-coverage-test
Open

Parameterize CodeCoverage test on IncludeTestAssembly (#52029)#54514
Evangelink wants to merge 1 commit into
dotnet:mainfrom
Evangelink:dev/amauryleve/fix-52029-coverage-test

Conversation

@Evangelink
Copy link
Copy Markdown
Member

Fixes #52029

Per @Youssef1313's comment:

What will be needed here is to make the test parameterized on the value of IncludeTestAssembly. When it's set to true, the test is expected to fail and investigation is needed. When it's false, the test will pass.

Historically, IncludeTestAssembly was false in MTP. Then later, it was changed to true, causing this test to fail and later users saw the issue, then CodeCoverage reverted IncludeTestAssembly back to be false by default.

Changes

test/dotnet.Tests/CommandTests/Test/GivenDotnetTestBuildsAndRunsTestsWithArtifacts.cs:

  • Replaces WindowsOnlyTheory with Theory so the test runs on Linux/macOS again.
  • Adds a bool includeTestAssembly parameter. The test writes a coverage.config containing <IncludeTestAssembly>true|false</IncludeTestAssembly> and forwards it via --coverage-settings. This decouples the test from any future flip of the Microsoft.CodeCoverage default.
  • [InlineData(..., false)] cases run on every OS (no platform skip).
  • [InlineData(..., true, Skip = "...")] cases stay skipped (with the issue link) because IncludeTestAssembly=true still triggers the unresolved BadImageFormatException crash that needs separate investigation.

Verification

Ran locally on Windows:

Total: 4, Errors: 0, Failed: 0, Skipped: 2
- (Debug, includeTestAssembly: False)   PASS
- (Release, includeTestAssembly: False) PASS
- (Debug, includeTestAssembly: True)    SKIP -> https://github.com/dotnet/sdk/issues/52029
- (Release, includeTestAssembly: True)  SKIP -> https://github.com/dotnet/sdk/issues/52029

Unskips RunTestProjectWithCodeCoverage_ShouldReturnExitCodeGenericFailure on Linux/macOS by making it explicit about the IncludeTestAssembly value used by Microsoft.CodeCoverage.

- Replaces WindowsOnlyTheory with Theory; the test now runs on all platforms when IncludeTestAssembly is false.

- Writes a coverage.config and passes it via --coverage-settings so the test no longer depends on the default value of IncludeTestAssembly in Microsoft.CodeCoverage.

- IncludeTestAssembly=true cases remain skipped pending investigation of the underlying BadImageFormatException crash referenced by the issue.

Fixes dotnet#52029

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 29, 2026 20:21
@Evangelink Evangelink requested a review from a team as a code owner May 29, 2026 20:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates a dotnet test --coverage regression test to be resilient to future changes in Microsoft.CodeCoverage defaults by explicitly controlling the IncludeTestAssembly setting, while re-enabling coverage validation on Linux/macOS for the non-crashing configuration.

Changes:

  • Parameterized the code coverage test on IncludeTestAssembly and wrote an explicit coverage.config passed via --coverage-settings.
  • Replaced WindowsOnlyTheory with Theory so the IncludeTestAssembly=false scenarios run cross-platform.
  • Kept IncludeTestAssembly=true scenarios present but skipped with an issue link due to the known crash.
Show a summary per file
File Description
test/dotnet.Tests/CommandTests/Test/GivenDotnetTestBuildsAndRunsTestsWithArtifacts.cs Parameterizes the coverage test and forwards explicit coverage settings; re-enables cross-platform execution for the passing configuration while skipping the known-crashing one.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

[InlineData(TestingConstants.Debug, true, Skip = "https://github.com/dotnet/sdk/issues/52029")]
[InlineData(TestingConstants.Release, true, Skip = "https://github.com/dotnet/sdk/issues/52029")]
[Theory]
public void RunTestProjectWithCodeCoverage_ShouldReturnExitCodeGenericFailure(string configuration, bool includeTestAssembly)
[InlineData(TestingConstants.Release, false)]
// When IncludeTestAssembly is true, the test process crashes with BadImageFormatException.
// See: https://github.com/dotnet/sdk/issues/52029
[InlineData(TestingConstants.Debug, true, Skip = "https://github.com/dotnet/sdk/issues/52029")]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as this is still skipped, original issue shouldn't be closed with this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants