Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSTest.TestAdapter 3.2.0 generates coverage report for 'Microsoft.ApplicationInsights' package #2816

Closed
dxynnez opened this issue May 6, 2024 · 5 comments

Comments

@dxynnez
Copy link

dxynnez commented May 6, 2024

Describe the bug

After upgrading to MSTest.TestAdapter >= 3.2.0, we notice that the code coverage report would now include the 'Microsoft.ApplicationInsights' package.

We run our tests with:
dotnet test --no-build --no-restore --configuration release --logger trx --collect "XPlat Code Coverage" --results-directory TestResults\ /p:ExcludeByAttribute="CompilerGeneratedAttribute"

Here is a sample coverage.cobertura.xml file:

<packages>
    <package name="Microsoft.ApplicationInsights" line-rate="0" branch-rate="0" complexity="4821">
      <classes>
        <class name="Microsoft.ApplicationInsights.ActivityExtensions" filename="/_/BASE/src/Microsoft.ApplicationInsights/ActivityExtensions.cs" line-rate="0" branch-rate="0" complexity="7">
          <methods>
            <method name="TryRun" signature="(System.Action)" line-rate="0" branch-rate="0" complexity="4">
              <lines>
                <line number="24" hits="0" branch="True" condition-coverage="0% (0/2)">
                  <conditions>
                    <condition number="5" type="jump" coverage="0%" />
                  </conditions>
                </line>
                <line number="26" hits="0" branch="False" />
                <line number="29" hits="0" branch="True" condition-coverage="0% (0/2)">
                  <conditions>
                    <condition number="22" type="jump" coverage="0%" />
                  </conditions>
                </line>
                <line number="31" hits="0" branch="False" />
                <line number="34" hits="0" branch="False" />
              </lines>
            </method>

We do notice that the 'Microsoft.ApplicationInsights' became a new transitive dependency for 'MSTest.TestAdapter', starting from v3.2.0, but we are not sure how come it would affect our test coverage report; and we are not using app insight at all. Is there a way to tell dotnet test to not include the 'Microsoft.ApplicationInsights' package?

Steps To Reproduce

  1. Upgrade MSTest.TestAdapter to >= 3.2.0
  2. run tests with dotnet test --no-build --no-restore --configuration release --logger trx --collect "XPlat Code Coverage" --results-directory TestResults\ /p:ExcludeByAttribute="CompilerGeneratedAttribute"
  3. check the coverage.cobertura.xml file under the 'TestResults' folder and notice that the 'Microsoft.ApplicationInsights' package is included in the report

Expected behavior

Report should not include the 'Microsoft.ApplicationInsights' package as it's a transitive dependency from 'MSTest.TestAdapter'

Actual behavior

Report includes the 'Microsoft.ApplicationInsights' package

@Evangelink
Copy link
Member

@MarcoRossignoli @jakubch1 Is it possible for us to add some exclusions automatically so that users don't have to exclude the telemetry package?

@MarcoRossignoli
Copy link
Contributor

MarcoRossignoli commented May 6, 2024

For what I see it's using coverlet and it shouldn't appear because we use heuristic and we don't have in local source files of it. So I suppose that's it's not the only extra package in the report or?
It's more an issue of coverlet in case https://github.com/coverlet-coverage/coverlet/issues

It's already excluding something https://github.com/coverlet-coverage/coverlet/blob/master/test/coverlet.core.tests/Coverage/InstrumenterHelper.cs#L109 but not for instance mstest so also appinsight should not be there.

@Evangelink
Copy link
Member

Alright so closing issue here then, thanks @MarcoRossignoli!

@Evangelink Evangelink closed this as not planned Won't fix, can't repro, duplicate, stale May 6, 2024
@dxynnez
Copy link
Author

dxynnez commented May 6, 2024

Thanks @Evangelink and @MarcoRossignoli . However, the only extra package I am seeing in the report is the 'Microsoft.ApplicationInsights'.

Should I open an issue at the coverlet side instead?

@Evangelink
Copy link
Member

@dxynnez yes please do!

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

No branches or pull requests

3 participants