Skip to content

dotnet-coverage does not exclude test assemblies while dotnet run / dotnet test do with Microsoft.Testing.Platform #156

@MattKotsenas

Description

@MattKotsenas

I'm seeing different behaviors for the IncludeTestAssembly property depending on how I invoke a test using Microsoft.Testing.Platform. It's unclear to me if this is expected behavior, but from my understanding / perspective, these scenarios should all be using Microsoft.Testing.Platform, and thus should all behave the same.

Repro steps

  1. Clone repo
git clone https://github.com/microsoft/codecoverage.git
cd codecoverage/samples/Algorithms/tests/Algorithms.Core.Tests/
  1. Add TestingPlatformDotnetTestSupport
<PropertyGroup>
  <TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
</PropertyGroup>

dotnet run

dotnet run --coverage --coverage-output report.cobertura.xml --coverage-output-format cobertura

Result: Tests are not included in report.cobertura.xml

dotnet test

dotnet test -- --coverage --coverage-output report.cobertura.xml --coverage-output-format cobertura

Result: Tests are not included in report.cobertura.xml

dotnet coverage

dotnet tool install -g dotnet-coverage
dotnet-coverage collect --output report.cobertura.xml --output-format cobertura "dotnet run --no-build"

Result: Test are included in report.cobertura.xml

This is Scenario04 in the samples. Given that this is also supposed to be using the MSTest runner according to https://github.com/microsoft/codecoverage/blob/main/samples/Algorithms/README.md, I'd expect this to output the same as the other two entrypoints.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions