FineCodeCoverage icon indicating copy to clipboard operation
FineCodeCoverage copied to clipboard

Crash: No code coverage generated

Open Lukemtesta opened this issue 3 years ago • 2 comments

Microsoft Visual Studio Professional 2022 (64-bit) - Current Version 17.1.0 .NET Framework Version 4.8.04084

Steps to reproduce

Project A .Net 6.0 Project B .Net 6.0 MSTest Unit Test Project -> project dependencies to A and B.

Run test via Test Explorer with right click on project and run tests.

MSTest Result All unit tests discovered, ran and passed in visual studio

FCC Result No report generated. Exception reported in the output tab. No changes to the Fine Code Coverage tab. Only Project A exists in coverage file. Main project (project B) is not present in coverage file.

Coverage file generated

coverage line-rate="1" branch-rate="1" version="1.9" timestamp="1656335884" lines-covered="0" lines-valid="0" branches-covered="0" branches-valid="0" sources / packages package name="ghUnitTestDefines" line-rate="1" branch-rate="1" complexity="0" classes / /package /packages /coverage

.runsettings file

EnvironmentVariables !--Change this if your system has redefined the build root path-- BUILD_ROOT......\HippoR6Build/BUILD_ROOT /EnvironmentVariables

MSTest
MapInconclusiveToFailedTrue/MapInconclusiveToFailed !-- -- CaptureTraceOutputTrue/CaptureTraceOutput !-- -- DeleteDeploymentDirectoryAfterTestRunIsCompleteFalse/DeleteDeploymentDirectoryAfterTestRunIsComplete !-- -- DeploymentEnabledFalse/DeploymentEnabled !-- -- !-- -- AssemblyResolution Directory path="$(BUILD_ROOT)debug\bin" includeSubDirectories="false"/
Directory path="$(BUILD_ROOT)release\bin" includeSubDirectories="false"/
/AssemblyResolution
/MSTest

Log:

Fine Code Coverage : See option RunMsCodeCoverage for a better ( Beta ) experience. https://github.com/FortuneN/FineCodeCoverage/blob/master/README.md

Fine Code Coverage : Coverage collected when tests finish. RunInParallel option true for immediate

Fine Code Coverage : ================================== START ==================================

Fine Code Coverage : Run Coverlet (ghNetworkingUnitTests)

Fine Code Coverage : Coverlet Run (ghNetworkingUnitTests) Arguments "C:\Users\pc\Documents\gh\git\HippoR6Build\debug\bin\fine-code-coverage\build-output\ghNetworkingUnitTests.dll" --format "cobertura" --exclude-by-file "**/Migrations/*" --exclude-by-attribute "GeneratedCode" --include-test-assembly --target "dotnet" --threshold-type line --threshold-stat total --threshold 0 --output "C:\Users\pc\Documents\gh\git\HippoR6Build\debug\bin\fine-code-coverage\coverage-tool-output\ghNetworkingUnitTests.coverage.xml" --targetargs "test ""C:\Users\pc\Documents\gh\git\HippoR6Build\debug\bin\fine-code-coverage\build-output\ghNetworkingUnitTests.dll"" --nologo --blame --settings ""C:\Users\pc\Documents\gh\git\HippoR6\Testing\UnitTesting\TestSettings.runsettings"" --results-directory ""C:\Users\pc\Documents\gh\git\HippoR6Build\debug\bin\fine-code-coverage\coverage-tool-output"" --diag ""C:\Users\pc\Documents\gh\git\HippoR6Build\debug\bin\fine-code-coverage\coverage-tool-output/diagnostics.log"" "

Fine Code Coverage : Coverlet Run (ghNetworkingUnitTests) Unable to instrument module: C:\Users\pc\Documents\gh\git\HippoR6Build\debug\bin\fine-code-coverage\build-output\ghNetworking.dll because : No symbol found for file: C:\Users\pc\Documents\gh\git\HippoR6Build\debug\bin\fine-code-coverage\build-output\ghNetworking.dll Unable to instrument module: C:\Users\pc\Documents\gh\git\HippoR6Build\debug\bin\fine-code-coverage\build-output\ghNetworkingUnitTests.dll because : No symbol found for file: C:\Users\pc\Documents\gh\git\HippoR6Build\debug\bin\fine-code-coverage\build-output\ghNetworkingUnitTests.dll Starting test execution, please wait... Logging Vstest Diagnostics in file: C:\Users\pc\Documents\gh\git\HippoR6Build\debug\bin\fine-code-coverage\coverage-tool-output\diagnostics.log A total of 1 test files matched the specified pattern. The active test run was aborted. Reason: Test host process crashed : Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object. at ghNetworking.UDPNodeSender1.RunUDPProcessor() at System.Threading.Thread.StartCallback() The active Test Run was aborted because the host process exited unexpectedly. Please inspect the call stack above, if available, to get more information about where the exception originated from. The test running when the crash occurred: Attachments: test_namespace.UDP.UDPNodeReceiver This test may, or may not be the source of the crash. C:\Users\pc\Documents\gh\git\HippoR6Build\debug\bin\fine-code-coverage\coverage-tool-output\2a17ec81-397a-4664-823c-86252f62084c\Sequence_502690dde8914e1f80c3dbd7e7478837.xml Test Run Aborted with error System.Exception: One or more errors occurred. ---> System.Exception: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.. ---> System.Exception: An existing connection was forcibly closed by the remote host. at System.Net.Sockets.NetworkStream.Read(Span1 buffer) --- End of inner exception stack trace --- at System.Net.Sockets.NetworkStream.Read(Span1 buffer) at System.Net.Sockets.NetworkStream.ReadByte() at System.IO.BinaryReader.Read7BitEncodedInt() at System.IO.BinaryReader.ReadString() at Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.LengthPrefixCommunicationChannel.NotifyDataAvailable() at Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.TcpClientExtensions.MessageLoopAsync(TcpClient client, ICommunicationChannel channel, Action1 errorHandler, CancellationToken cancellationToken) --- End of inner exception stack trace ---.

Calculating coverage result... Generating report 'C:\Users\pc\Documents\gh\git\HippoR6Build\debug\bin\fine-code-coverage\coverage-tool-output\ghNetworkingUnitTests.coverage.xml' +-------------------+------+--------+--------+ | Module | Line | Branch | Method | +-------------------+------+--------+--------+ | ghUnitTestDefines | 100% | 100% | 100% | +-------------------+------+--------+--------+

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

Fine Code Coverage : Completed coverage for (ghNetworkingUnitTests) : 00:00:05.9844527

Fine Code Coverage : ReportGenerator Run Arguments [reporttype:Cobertura] "-targetdir:C:\Users\pc\Documents\gh\git\HippoR6Build\debug\bin\fine-code-coverage\coverage-tool-output" "-reports:C:\Users\pc\Documents\gh\git\HippoR6Build\debug\bin\fine-code-coverage\coverage-tool-output\ghNetworkingUnitTests.coverage.xml" "-reporttypes:Cobertura"

Fine Code Coverage : ReportGenerator Run [reporttype:Cobertura] 2022-06-27T14:18:04: Arguments 2022-06-27T14:18:04: -targetdir:C:\Users\pc\Documents\gh\git\HippoR6Build\debug\bin\fine-code-coverage\coverage-tool-output 2022-06-27T14:18:04: -reports:C:\Users\pc\Documents\gh\git\HippoR6Build\debug\bin\fine-code-coverage\coverage-tool-output\ghNetworkingUnitTests.coverage.xml 2022-06-27T14:18:04: -reporttypes:Cobertura 2022-06-27T14:18:04: Writing report file 'C:\Users\pc\Documents\gh\git\HippoR6Build\debug\bin\fine-code-coverage\coverage-tool-output\Cobertura.xml' 2022-06-27T14:18:04: Report generation took 0.1 seconds

Fine Code Coverage : ReportGenerator Run Arguments [reporttype:HtmlInline_AzurePipelines] "-targetdir:C:\Users\pc\Documents\gh\git\HippoR6Build\debug\bin\fine-code-coverage\coverage-tool-output" "-reports:C:\Users\pc\Documents\gh\git\HippoR6Build\debug\bin\fine-code-coverage\coverage-tool-output\Cobertura.xml" "-plugins:C:\USERS\PC\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\17.0_A1A85EA2\EXTENSIONS\KPL3I3Y0.HD0\ReportGeneratorPlugins.dll" "-reporttypes:FccLight" "riskHotspotsAnalysisThresholds:metricThresholdForCyclomaticComplexity=30" "riskHotspotsAnalysisThresholds:metricThresholdForCrapScore=15" "riskHotspotsAnalysisThresholds:metricThresholdForNPathComplexity=200"

Fine Code Coverage : ReportGenerator Run [reporttype:HtmlInline_AzurePipelines] 2022-06-27T14:18:05: Arguments 2022-06-27T14:18:05: -targetdir:C:\Users\pc\Documents\gh\git\HippoR6Build\debug\bin\fine-code-coverage\coverage-tool-output 2022-06-27T14:18:05: -reports:C:\Users\pc\Documents\gh\git\HippoR6Build\debug\bin\fine-code-coverage\coverage-tool-output\Cobertura.xml 2022-06-27T14:18:05: -plugins:C:\USERS\PC\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\17.0_A1A85EA2\EXTENSIONS\KPL3I3Y0.HD0\ReportGeneratorPlugins.dll 2022-06-27T14:18:05: -reporttypes:FccLight 2022-06-27T14:18:05: riskHotspotsAnalysisThresholds:metricThresholdForCyclomaticComplexity=30 2022-06-27T14:18:05: riskHotspotsAnalysisThresholds:metricThresholdForCrapScore=15 2022-06-27T14:18:05: riskHotspotsAnalysisThresholds:metricThresholdForNPathComplexity=200 2022-06-27T14:18:05: Writing report file 'C:\Users\pc\Documents\gh\git\HippoR6Build\debug\bin\fine-code-coverage\coverage-tool-output\index.html' 2022-06-27T14:18:05: Report generation took 0.4 seconds

Fine Code Coverage : Processing cobertura

Fine Code Coverage : Processing report

Fine Code Coverage : ================================== DONE ==================================

Lukemtesta avatar Jun 27 '22 13:06 Lukemtesta

I suspect that that this is due to how fcc copies build output

https://github.com/FortuneN/FineCodeCoverage#old-style-coverage

Dlls are copied to a sub folder of project output folder which may affect your tests. The alternative is to set the option AdjacentBuildOutput to true.

If that is not the issue then UseDataCollector see https://github.com/FortuneN/FineCodeCoverage#coverlet-specific

You could also switch to RunMsCodeCoverage. https://github.com/FortuneN/FineCodeCoverage#how-to-utilize-ms-code-coverage-with-fcc-

tonyhallett avatar Jun 27 '22 17:06 tonyhallett

@Lukemtesta Did you resolve this ?

tonyhallett avatar Jun 28 '22 17:06 tonyhallett

@Lukemtesta Did you resolve this ?

tonyhallett avatar Sep 22 '22 15:09 tonyhallett