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

Only displaying test projects in coverage report after fresh install on latest VS, then nothing at all #415

Closed
IsaacSherman opened this issue Apr 8, 2024 · 9 comments

Comments

@IsaacSherman
Copy link

IsaacSherman commented Apr 8, 2024

Installed product versions

  • Visual Studio: VS 2022 Professional 17.10.0 Preview 2.0
  • This extension:1.1.214

Description

After switching to the latest preview version of VS and installing FCC, neither the ticks showing the line is covered nor the coverage report are being displayed/generated correctly.

Steps to recreate

  1. Install latest Preview version of VS 2022
  2. Install FCC
  3. Run unit tests
  4. Log indicates that FCC runs, but it doesn't find a cobertura file and quits

Current behavior

Edit: Initially generated a report for the test project, but stopped doing even that as I tried to reproduce for this report.
Log indicates that FCC runs, but it doesn't generate a report. If I run it without MSCodeCoverage, it generates cobertura files but then doesn't find anything at all as being covered.

Expected behavior

Should show results on test completion

Side Notes

Here's the log:
Fine Code Coverage 4/8/2024 10:20:44 AM: Ms code coverage
Fine Code Coverage 4/8/2024 10:20:53 AM: No cobertura files for ms code coverage.
Fine Code Coverage 4/8/2024 10:20:53 AM: ================================== DONE ==================================
And here's the log when I run FCC after turning of MSCodeCoverage:
Fine Code Coverage 4/8/2024 10:20:44 AM: Ms code coverage
Fine Code Coverage 4/8/2024 10:20:53 AM: No cobertura files for ms code coverage.
Fine Code Coverage 4/8/2024 10:20:53 AM: ================================== DONE ==================================
Fine Code Coverage 4/8/2024 10:23:24 AM: See option RunMsCodeCoverage for a better ( Beta ) experience. https://github.com/FortuneN/FineCodeCoverage/blob/master/README.md
Fine Code Coverage 4/8/2024 10:23:24 AM: ================================== START ==================================
Fine Code Coverage 4/8/2024 10:23:24 AM: Copy : C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\AppName.exe -> C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\build-output\AppName.exe
Copy : C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\AppName.pdb -> C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\build-output\AppName.pdb
Copy : C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\AppName.dll -> C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\build-output\AppName.dll
Copy : C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\AppName.Tests.deps.json -> C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\build-output\AppName.Tests.deps.json
Copy : C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\AppName.Tests.pdb -> C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\build-output\AppName.Tests.pdb
Copy : C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\AppName.deps.json -> C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\build-output\AppName.deps.json
Copy : C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\CoverletSourceRootsMapping_AppName.Tests -> C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\build-output\CoverletSourceRootsMapping_AppName.Tests
Copy : C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\AppName.Tests.dll -> C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\build-output\AppName.Tests.dll
Copy : C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\AppName.Tests.runtimeconfig.json -> C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\build-output\AppName.Tests.runtimeconfig.json
Copy : C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\AppName.runtimeconfig.json -> C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\build-output\AppName.runtimeconfig.json
File synchronization duration : 00:00:00.0698628
Fine Code Coverage 4/8/2024 10:23:24 AM: Run Coverlet (AppName.Tests)
Fine Code Coverage 4/8/2024 10:23:24 AM: Coverlet Run (AppName.Tests) - Arguments
"C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\build-output\AppName.Tests.dll"
--format "cobertura"
--include "[AppName]"
--exclude-by-file "**/Migrations/
"
--exclude-by-attribute GeneratedCode
--target "dotnet"
--threshold-type line
--threshold-stat total
--threshold 0
--output "C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\coverage-tool-output\AppName.Tests.coverage.xml"
--targetargs "test ""C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\build-output\AppName.Tests.dll"" --nologo --blame --results-directory ""C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\coverage-tool-output"" --diag ""C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\coverage-tool-output/diagnostics.log"" "
Fine Code Coverage 4/8/2024 10:23:35 AM: Coverlet Run (AppName.Tests) - Output
Unable to instrument module: C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\build-output\AppName.dll
Mono.Cecil.ResolutionException: Failed to resolve System.Windows.Threading.DispatcherPriority
at Mono.Cecil.Mixin.CheckedResolve(TypeReference self)
at Mono.Cecil.MetadataBuilder.GetConstantType(TypeReference constant_type, Object constant)
at Mono.Cecil.MetadataBuilder.AddConstant(IConstantProvider owner, TypeReference type)
at Mono.Cecil.MetadataBuilder.AddParameter(UInt16 sequence, ParameterDefinition parameter, ParamTable table)
at Mono.Cecil.MetadataBuilder.AddParameters(MethodDefinition method)
at Mono.Cecil.MetadataBuilder.AddMethod(MethodDefinition method)
at Mono.Cecil.MetadataBuilder.AddMethods(TypeDefinition type)
at Mono.Cecil.MetadataBuilder.AddType(TypeDefinition type)
at Mono.Cecil.MetadataBuilder.AddTypes()
at Mono.Cecil.MetadataBuilder.BuildTypes()
at Mono.Cecil.MetadataBuilder.BuildModule()
at Mono.Cecil.MetadataBuilder.BuildMetadata()
at Mono.Cecil.ModuleWriter.<>c.b__2_0(MetadataBuilder builder, MetadataReader _)
at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func3 read) at Mono.Cecil.ModuleWriter.BuildMetadata(ModuleDefinition module, MetadataBuilder metadata) at Mono.Cecil.ModuleWriter.Write(ModuleDefinition module, Disposable1 stream, WriterParameters parameters)
at Mono.Cecil.ModuleWriter.WriteModule(ModuleDefinition module, Disposable1 stream, WriterParameters parameters) at Mono.Cecil.ModuleDefinition.Write(Stream stream, WriterParameters parameters) at Coverlet.Core.Instrumentation.Instrumenter.InstrumentModule() in /_/src/coverlet.core/Instrumentation/Instrumenter.cs:line 337 at Coverlet.Core.Instrumentation.Instrumenter.Instrument() in /_/src/coverlet.core/Instrumentation/Instrumenter.cs:line 153 at Coverlet.Core.Coverage.PrepareModules() in /_/src/coverlet.core/Coverage.cs:line 135 Starting test execution, please wait... Logging Vstest Diagnostics in file: C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\coverage-tool-output\diagnostics.log A total of 1 test files matched the specified pattern. [xUnit.net 00:00:07.97] AppName.Tests.Controls.Calibration.EnergyAndFwhmTableWrapperViewModelIntegrationTestShould.ShouldRemovePointsCleanlyAndAdd3Points [FAIL] Failed AppName.Tests.Controls.Calibration.EnergyAndFwhmTableWrapperViewModelIntegrationTestShould.ShouldRemovePointsCleanlyAndAdd3Points [517 ms] Error Message: Expected _energyVm.EnergyTableEntrySource.Count to be 71, but found 6 (difference of -65). Stack Trace: at FluentAssertions.Execution.XUnit2TestFramework.Throw(String message) at FluentAssertions.Execution.TestFrameworkProvider.Throw(String message) at FluentAssertions.Execution.DefaultAssertionStrategy.HandleFailure(String message) at FluentAssertions.Execution.AssertionScope.FailWith(Func1 failReasonFunc)
at FluentAssertions.Execution.AssertionScope.FailWith(Func1 failReasonFunc) at FluentAssertions.Execution.AssertionScope.FailWith(String message, Object[] args) at FluentAssertions.Numeric.NumericAssertions2.Be(T expected, String because, Object[] becauseArgs)
at AppName.Tests.Controls.Calibration.EnergyAndFwhmTableWrapperViewModelIntegrationTestShould.ShouldRemovePointsCleanlyAndAdd3Points() in C:\Dev\App-AppName\tests\AppName.Tests\Controls\Calibration\EnergyAndFwhmTableWrapperViewModelIntegrationTestShould.cs:line 227
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
Failed! - Failed: 1, Passed: 165, Skipped: 0, Total: 166, Duration: 7 s - AppName.Tests.dll (net8.0)

Calculating coverage result...
Generating report 'C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\coverage-tool-output\AppName.Tests.coverage.xml'
+--------+------+--------+--------+
| Module | Line | Branch | Method |
+--------+------+--------+--------+

+---------+------+--------+--------+
| | Line | Branch | Method |
+---------+------+--------+--------+
| Total | 0% | 0% | 0% |
+---------+------+--------+--------+
| Average | 0% | 0% | 0% |
+---------+------+--------+--------+
Fine Code Coverage 4/8/2024 10:23:35 AM: Completed coverage for (AppName.Tests) : 00:00:10.6782479
Fine Code Coverage 4/8/2024 10:23:35 AM: ReportGenerator Run Arguments [reporttype:Cobertura]
"-targetdir:C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\coverage-tool-output"
"-reports:C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\coverage-tool-output\AppName.Tests.coverage.xml"
"-reporttypes:Cobertura"
Fine Code Coverage 4/8/2024 10:23:36 AM: ReportGenerator Run [reporttype:Cobertura]
2024-04-08T10:23:35: Arguments
2024-04-08T10:23:35: -targetdir:C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\coverage-tool-output
2024-04-08T10:23:35: -reports:C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\coverage-tool-output\AppName.Tests.coverage.xml
2024-04-08T10:23:35: -reporttypes:Cobertura
2024-04-08T10:23:36: Writing report file 'C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\coverage-tool-output\Cobertura.xml'
2024-04-08T10:23:36: Report generation took 0.1 seconds
Fine Code Coverage 4/8/2024 10:23:36 AM: ReportGenerator Run Arguments [reporttype:HtmlInline_AzurePipelines]
"-targetdir:C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\coverage-tool-output"
"-reports:C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\coverage-tool-output\Cobertura.xml"
"-plugins:c:\users\isherman\appdata\local\microsoft\visualstudio\17.0_413ce694\extensions\s1nmmudq.kvf\ReportGeneratorPlugins.dll"
"-reporttypes:FccLight"
"riskHotspotsAnalysisThresholds:metricThresholdForCyclomaticComplexity=30"
"riskHotspotsAnalysisThresholds:metricThresholdForCrapScore=15"
"riskHotspotsAnalysisThresholds:metricThresholdForNPathComplexity=200"
Fine Code Coverage 4/8/2024 10:23:36 AM: ReportGenerator Run [reporttype:HtmlInline_AzurePipelines]
2024-04-08T10:23:36: Arguments
2024-04-08T10:23:36: -targetdir:C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\coverage-tool-output
2024-04-08T10:23:36: -reports:C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\coverage-tool-output\Cobertura.xml
2024-04-08T10:23:36: -plugins:c:\users\isherman\appdata\local\microsoft\visualstudio\17.0_413ce694\extensions\s1nmmudq.kvf\ReportGeneratorPlugins.dll
2024-04-08T10:23:36: -reporttypes:FccLight
2024-04-08T10:23:36: riskHotspotsAnalysisThresholds:metricThresholdForCyclomaticComplexity=30
2024-04-08T10:23:36: riskHotspotsAnalysisThresholds:metricThresholdForCrapScore=15
2024-04-08T10:23:36: riskHotspotsAnalysisThresholds:metricThresholdForNPathComplexity=200
2024-04-08T10:23:36: Writing report file 'C:\Dev\App-AppName\tests\AppName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\coverage-tool-output\index.html'
2024-04-08T10:23:36: Report generation took 0.1 seconds
Fine Code Coverage 4/8/2024 10:23:36 AM: Processing cobertura
Fine Code Coverage 4/8/2024 10:23:36 AM: Processing report
Fine Code Coverage 4/8/2024 10:23:36 AM: ================================== DONE ==================================

@IsaacSherman IsaacSherman changed the title Only displaying test projects in coverage report after fresh install on latest VS Only displaying test projects in coverage report after fresh install on latest VS, then nothing at all Apr 8, 2024
@tonyhallett
Copy link
Collaborator

Does FCC work with the non preview version of Visual Studio ? What type of project is AppName ? Are you running tests in Debug mode ? What dependencies does AppName have ?

You can following the instructions in #413 for updating the coverlet version.

@IsaacSherman
Copy link
Author

I have different problems with it on the current version of VS (which I'll call the old version for clarity). To get it to work today, I had to run the tests in Preview, and then observe the coverage in the old version. It's very hit or miss if I run it in the old version. It used to work fine, but it stopped in the last couple of weeks. Right now it's working in the old version, after running the tests in Preview. However, running the tests in the old version causes a large hang, which I think might be explained by the FCC log, which I'll attach separately.
Old Version Fcc.txt
Preview Fcc.txt (this is if I run with MSCodeCoverage)
Working?Fcc.txt This one seems to be the log, from Old Version, that worked, but as you can see it generated a large amount of warnings...

AppName is a WPF Application running .Net 8.
I think I'm running the tests in Debug mode, I'm not changing my configuration before I tell it to run (I'm not Debugging my tests, if that's what you mean).
As for packages, I have several. Most notably Telerik, Prism and SciChart. There are numerous smaller packages as well. I don't think it's a conflict as it is currently working at least in the way I described above. I can get you an exhaustive list if you feel it's necessary. It's WPF, not MAUI, so there's that.

@tonyhallett
Copy link
Collaborator

Is the version of FCC the same in Visual Studio and Visual Studio Preview ? Can you show the generated runsettings when using ms code coverage.

@tonyhallett
Copy link
Collaborator

If you can try to update coverlet by using the instructions in the link provided it may resolve this issue - see coverlet-coverage/coverlet#1221 (comment)

@IsaacSherman
Copy link
Author

Is the version of FCC the same in Visual Studio and Visual Studio Preview ? Can you show the generated runsettings when using ms code coverage.

No, the old version is 209. It's set to keep it updated automatically, which doesn't seem to be working. Where do I look for the runsettings?

If you can try to update coverlet by using the instructions in the link provided it may resolve this issue - see coverlet-coverage/coverlet#1221 (comment)

And I'm not sure what I'm supposed to do based on the comment you linked- I see information about copying dlls from the refs dir but don't see anything about updating coverlet. FYI, I have to go for the evening, but I'll revisit this in the morning. Thank you for your help so far.

@tonyhallett
Copy link
Collaborator

instructions in #413 for updating the coverlet version. The coverlet link suggests a workaround to your issue.

Please ensure FCC version is consistent across Vs versions.

The runsettings is in the bin directory within an FCC directory. We need to check that the SUT has been included in the coverage.

@IsaacSherman
Copy link
Author

No luck, after updating the coverlet to 6.0.2, I still get similar logs. Running with MSCode enabled gives me the No Cobertura messages and running without it gives me the log with the exceptions and 0% coverage.

@IsaacSherman
Copy link
Author

Good news! The workaround (copying WindowsBase.dll) seems to have worked- I can run it without MSCodeCoverage and get my coverage- running with it has the old result. Thank you so much, do you want me to close this issue?

@tonyhallett
Copy link
Collaborator

Great that it has worked. When you updated coverlet did you add the UseDataCollector project property in your test project ?

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

No branches or pull requests

2 participants