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

Report only includes test assembly #188

Closed
MaQy opened this issue Oct 13, 2021 · 15 comments
Closed

Report only includes test assembly #188

MaQy opened this issue Oct 13, 2021 · 15 comments
Labels
waiting for feedback Need feedback or more information

Comments

@MaQy
Copy link

MaQy commented Oct 13, 2021

Installed product versions

  • Visual Studio: 2019 Professional
  • This extension: 1.1.141

Description

The generated report is only including coverage for the test assembly, none of the referenced projects are shown. I also included the property UseDataCollector just in case but nothing changed.

Side Notes

I'm using xunit.

imagen

This is the output from FCC:


Fine Code Coverage : Run Coverage Tool (Loc.Cms.UnitTests)

Fine Code Coverage : Coverlet Collector Run (Loc.Cms.UnitTests) Arguments 
"E:\git\LocCMS\api\source\Loc.Cms.UnitTests\bin\Debug\net5.0\fine-code-coverage\build-output\Loc.Cms.UnitTests.dll" --blame --nologo --diag "E:\git\LocCMS\api\source\Loc.Cms.UnitTests\bin\Debug\net5.0\fine-code-coverage\coverage-tool-output/diagnostics.log" --settings "E:\git\LocCMS\api\source\Loc.Cms.UnitTests\bin\Debug\net5.0\fine-code-coverage\coverage-tool-output/FCC.runsettings" --results-directory "E:\git\LocCMS\api\source\Loc.Cms.UnitTests\bin\Debug\net5.0\fine-code-coverage\coverage-tool-output"

Fine Code Coverage : Coverlet Collector Run (Loc.Cms.UnitTests)
Starting test execution, please wait...
Logging Vstest Diagnostics in file: E:\git\LocCMS\api\source\Loc.Cms.UnitTests\bin\Debug\net5.0\fine-code-coverage\coverage-tool-output\diagnostics.log
A total of 1 test files matched the specified pattern.

Attachments:
  E:\git\LocCMS\api\source\Loc.Cms.UnitTests\bin\Debug\net5.0\fine-code-coverage\coverage-tool-output\9c4e3aee-85bd-45e0-8775-31ebb9159b7b\coverage.cobertura.xml
Passed!  - Failed:     0, Passed:  4950, Skipped:     5, Total:  4955, Duration: 1 m 29 s - Loc.Cms.UnitTests.dll (net5.0)

Fine Code Coverage : ReportGenerator Run Arguments [reporttype:Cobertura] 
"-targetdir:E:\git\LocCMS\api\source\Loc.Cms.UnitTests\bin\Debug\net5.0\fine-code-coverage\coverage-tool-output"
"-reports:E:\git\LocCMS\api\source\Loc.Cms.UnitTests\bin\Debug\net5.0\fine-code-coverage\coverage-tool-output\Loc.Cms.UnitTests.coverage.xml"
"-reporttypes:Cobertura"

Could you please point out what I'm doing wrong?

Thanks!

@tonyhallett
Copy link
Collaborator

Have you looked at the diagnostics log ? What does the generated run settings look like ?

@MaQy
Copy link
Author

MaQy commented Oct 19, 2021

What should I look for in the diagnostics log? This is the only error I could find, I don't know if it is related in any way:

Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeModule.GetTypes()
   at System.Reflection.Assembly.GetTypes()
   at Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.TestPluginDiscoverer.GetTestExtensionsFromAssembly[TPluginInfo,TExtension](Assembly assembly, Dictionary`2 pluginInfos)
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
File name: 'Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
TpTrace Warning: 0 : 34052, 1, 2021/10/14, 12:42:49.024, 181114250227, vstest.console.dll, LoaderExceptions: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
File name: 'Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'

@tonyhallett
Copy link
Collaborator

Are you using run settings ?

Is your solution open source so I can look at it ?

Otherwise you will need to create minimal reproducible solution so that I can look at that.

@MaQy
Copy link
Author

MaQy commented Oct 19, 2021

No, I'm not using custom run settings. Unfortunately my project is private, I will try to reproduce it in a smaller project but I'm not sure if I will be able to (it's a fairly large solution so I don't think there is a simple way of replicating the same scenario).

@tonyhallett
Copy link
Collaborator

Can you describe your project. The frameworks you are using. Is it code generation ? Are you using microsoft fakes / aop weaving etc

@MaQy
Copy link
Author

MaQy commented Oct 19, 2021

Yes, it's basically the typical xunit test library testing an ASP.NET Core API in .NET 5. Apart from xunit I'm using Moq and FluentAssertions. I have .NET 5 source generators in the application side (not in the unit test project), can those be the cause of the issue?

@tonyhallett
Copy link
Collaborator

I think that source generators may need to be set up differently. Will come back to you

@tonyhallett
Copy link
Collaborator

tonyhallett commented Oct 19, 2021

From what I remember FCC excludes by attribute GeneratedCode. Can you check that is in the generated run settings.
If it is there then in a test project

<PropertyGroup Label="FineCodeCoverage">

  <ExcludeByAttribute>
  </ExcludeByAttribute>
</PropertyGroup>

or in vs options
image

remove the option.

If this does not work then we will need to check the coverlet documentation.

@tonyhallett
Copy link
Collaborator

Also, in the diagnostics do you see "Unable to instrument module...." ?

Could this coverlet issue possibly describe this issue.

This coverlet issue mentions source generators.

@JosefNemec
Copy link

I had the same issue (only test project being covered) when using NUnit. What fixed it for me was switching from NUnit's VS extension test adapter to NUnit test adapter nuget package.

@marbel82
Copy link

marbel82 commented Nov 3, 2021

@MaQy You can bypass coverlet bug.

When Fine Code Coverage print that some assembly (or class) is missing

Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces,...

You can manually copy missing assemblies to ...\bin\Debug\net5.0\, and then run tests.

In my case Fine Code Coverage began working.

@tonyhallett
Copy link
Collaborator

@marbel82
I cannot find any coverlet issue mentioning Microsoft.Bcl.AsyncInterfaces.
Is it a package reference issue instead ?

@marbel82
Copy link

marbel82 commented Nov 3, 2021

@tonyhallett I write only example. @MaQy wrote above that in the diagnostics log he has Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces,...

In my case Fine Code Coverage (more precisely coverlet) had a problem with:

Unable to instrument module: c:\SomeProject\Tests\Module.Tests\bin\Debug\net5.0-windows\Module.dll because : AssemblyResolutionException for 'PresentationFramework, Version=5.0.0.0,...

See coverlet-coverage/coverlet#1221 (comment)

@tonyhallett
Copy link
Collaborator

@marbel82 thanks for your work around.

@MaQy Is visual studio giving any warnings about AsyncInterfaces ?

@tonyhallett tonyhallett added the waiting for feedback Need feedback or more information label Nov 14, 2021
@tonyhallett
Copy link
Collaborator

@MaQy
Have you tried the workaround suggested.
If you cannot provide any further information I will have to close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for feedback Need feedback or more information
Projects
None yet
Development

No branches or pull requests

4 participants