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

Unable to instrument module #1007

Closed
subramaniamb opened this issue Nov 30, 2020 · 13 comments
Closed

Unable to instrument module #1007

subramaniamb opened this issue Nov 30, 2020 · 13 comments
Labels
waiting for customer Waiting for customer action

Comments

@subramaniamb
Copy link

subramaniamb commented Nov 30, 2020

I have a Xamarin Forms project which has unit tests written using NUnit targeting .Net Core 3.1. I am unable to get the code coverage generated due to an error/warning. Please find below the logs

/usr/local/bin/dotnet test /Users/runner/work/1/s/App.Test/App.Test.csproj --logger trx --results-directory /Users/runner/work/_temp --configuration Release /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=/Users/runner/work/1/s/TestResults/Coverage/ /p:CopyLocalLockFileAssemblies=true

/Users/runner/.nuget/packages/coverlet.msbuild/2.9.0/build/coverlet.msbuild.targets(31,5): warning : [coverlet] Unable to instrument module: /Users/runner/work/1/s/App.Test/bin/Release/netcoreapp3.1/Xamarin.Forms.Core.dll because : No symbol found for file: /Users/runner/work/1/s/App.Test/bin/Release/netcoreapp3.1/Xamarin.Forms.Core.dll [/Users/runner/work/1/s/App.Test/App.Test.csproj]

Test run for /Users/runner/work/1/s/App.Test/bin/Release/netcoreapp3.1/App.Test.dll(.NETCoreApp,Version=v3.1)
Microsoft (R) Test Execution Command Line Tool Version 16.7.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...

A total of 1 test files matched the specified pattern.
Results File: /Users/runner/work/_temp/_Mac-1606664309627_2020-11-29_15_42_20.trx

Test Run Successful.
Total tests: 15
     Passed: 15
 Total time: 1.4592 Seconds

Calculating coverage result...
  Generating report '/Users/runner/work/1/s/TestResults/Coverage/coverage.cobertura.xml'

+--------+------+--------+--------+
| Module | Line | Branch | Method |
+--------+------+--------+--------+

+---------+------+--------+--------+
|         | Line | Branch | Method |
+---------+------+--------+--------+
| Total   | 100% | 100%   | 100%   |
+---------+------+--------+--------+
| Average | NaN% | NaN%   | NaN%   |
+---------+------+--------+--------+
```

Any help to resolve the issue is highly appreciated. Thanks.
@subramaniamb
Copy link
Author

@MarcoRossignoli : I am kind of stuck with this issue. It would be really helpful if you can take a look at this issue. Thanks.

@MarcoRossignoli MarcoRossignoli added the untriaged To be investigated label Dec 4, 2020
@MarcoRossignoli
Copy link
Collaborator

MarcoRossignoli commented Dec 12, 2020

the warning for Xamarin.Forms.Core.dll shouldn't be an issue...you don't have source file of that so it's ok that coverlet skip it, it's a warning not an error.
Can you add some logging and attach here?Be sure to not share secrets sometimes it appears in logging
This is the guide https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/Troubleshooting.md#msbuild-integration

Also can you try to use collectors https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/VSTestIntegration.md?
There is a known issue that sometimes raise with msbuild and .NET tool driver https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/KnownIssues.md#1-vstest-stops-process-execution-earlydotnet-test

@MarcoRossignoli MarcoRossignoli added waiting for customer Waiting for customer action and removed untriaged To be investigated labels Dec 12, 2020
@subramaniamb
Copy link
Author

subramaniamb commented Dec 15, 2020

@MarcoRossignoli : I think I figured out the root cause of the issue. If I change the build configuration from Release to Debug, it is working. Any idea why?

@tonerdo
Copy link
Collaborator

tonerdo commented Dec 15, 2020

@subramaniamb it's a lot more ideal to run code coverage in Debug mode because that is when the structure of the compiled code most resembles the source code. In Release mode, applied optimizations could cause the final output to drastically deviate from the source code

@hello-ccchen
Copy link

hello-ccchen commented Dec 16, 2020

@MarcoRossignoli I have the same issue for net5.0 as well. 😭

Understand it label as known issue for now, appreciate if any solution.

@MarcoRossignoli
Copy link
Collaborator

@subramaniamb @hello-ccchen have you tried with collectors driver?

@subramaniamb
Copy link
Author

@subramaniamb @hello-ccchen have you tried with collectors driver?

I haven't. Could you please elaborate on collectors driver?

@MarcoRossignoli
Copy link
Collaborator

Collectors driver is a way where we use VSTest platform as orchestrator of coverage workflow. Today is the most reliable way to use coverlet due to default behavior of test platform.
Take a look at guide https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/VSTestIntegration.md
And known issue of other driver(.NET Tool and msbuild) https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/KnownIssues.md#vstest-stops-process-execution-early

@hello-ccchen
Copy link

@MarcoRossignoli

Collectors driver is a way where we use VSTest platform as orchestrator of coverage workflow. Today is the most reliable way to use coverlet due to default behavior of test platform.
Take a look at guide https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/VSTestIntegration.md
And known issue of other driver(.NET Tool and msbuild) https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/KnownIssues.md#vstest-stops-process-execution-early

Tried but not working. No code coverage at all
image

Report:

<coverage line-rate="1" branch-rate="1" version="1.9" timestamp="1610087877" lines-covered="0" lines-valid="0" branches-covered="0" branches-valid="0">
  <sources />
  <packages />
</coverage>

@MarcoRossignoli
Copy link
Collaborator

@hello-ccchen are you using last version of coverlet lib?

@hello-ccchen
Copy link

@hello-ccchen are you using last version of coverlet lib?

@MarcoRossignoli Yes. is the latest coverlet lib. My dotnet is the latest as well net5.0

@MarcoRossignoli
Copy link
Collaborator

Can yoy try to enable logs?Pay attention in logs could be present sensitive data

https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/Troubleshooting.md#collectors-integration

@MarcoRossignoli
Copy link
Collaborator

Closing for stale conversation, feel free to reopen if needed.

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

No branches or pull requests

4 participants