so im trying to make the code coverage working in my report.
I’m using azure devops on premise and therefore i have activated the ‘Enable Coverage’ option in the MSTest task (im using VS Entreprise)
So I do see that i have a .Coverage file being properly generated:
In my Test task run:
Attachments:
D:\agents\xxx_work\231\s\TestResults\5d23d3e6-3a57-42b5-a702-792ab09ac2dc\2024-11-15.16_21_07.coverage
Test Run Successful.
The file is indeed present and i have verified that it does contains code coverage report and percentages.
Then in the Run Code Analysis Sonar qube task, the .coverage file does seem picked up and analyzed:
Calling the TFS Processor executable...
Fetching code coverage report information from TFS...
Attempting to locate a test results (.trx) file...
Looking for TRX files in: D:\agents\xxx\_work\231\TestResults, D:\agents\xxx\_work\231\s\TestResults
The following test results files were found: D:\agents\PC393-WS10-D\_work\231\s\TestResults\2024-11-15_16_20_45.trx
Absolute path to coverage file: D:\agents\xxx\_work\231\s\TestResults\2024-11-15_16_20_45\In\xxx\2024-11-15.16_21_07.coverage
The following code coverage attachments were found from the trx files: D:\agents\xxx\_work\231\s\TestResults\2024-11-15_16_20_45\In\xxx\2024-11-15.16_21_07.coverage
Not using the fallback mechanism to detect binary coverage files.
Cxxonverting coverage file 'D:\agents\x\_work\231\s\TestResults\2024-11-15_16_20_45\In\xxx\2024-11-15.16_21_07.coverage' to 'D:\agents\xxx\_work\231\s\TestResults\2024-11-15_16_20_45\In\x\2024-11-15.16_21_07.coveragexml'.
Coverage report conversion completed successfully.
The TFS Processor has finished
Calling the SonarScanner CLI...
But then later there seems to be some issue locating the file it just converted??
INFO: ------------- Run sensors on module App.Desktop
INFO: Sensor HTML [web]
INFO: Sensor HTML [web] (done) | time=0ms
INFO: Sensor XML Sensor [xml]
INFO: 1 source file to be analyzed
INFO: 1/1 source file has been analyzed
INFO: Sensor XML Sensor [xml] (done) | time=15ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=0ms
INFO: Sensor IaC CloudFormation Sensor [iac]
INFO: 0 source files to be analyzed
INFO: 0/0 source files have been analyzed
INFO: Sensor IaC CloudFormation Sensor [iac] (done) | time=16ms
INFO: Sensor IaC AzureResourceManager Sensor [iac]
INFO: 0 source files to be analyzed
Im not sure if i need to stepup something special but it was my understanding that this should be done automatically if we were using the VS Entreprise code coverage feature?
Im using Visual Studio Code Coverage (using the Entreprise license).
I noticed this JaCoco sensor indeed, are you saying that it is overwritting the .NET sensor which actually found a report and replaced it with and empty report (since the jacoco found nothing?)
I do have a UI test project which contains some JavaScripts. Maybe this is why it tries to find a java code coverage report.
I’ll try to exclude the UI test project from the build and re-run it to see if it changes anything.
However I dont have JS in all my projects and does that doesnt have any JS scripts are behaving like this too.
In there it states that using Visual Studio Code Coverage that it should automatically generate the XML.
From what i can see in the log it seems to be detected and working properly. Not too sure why it doesnt show in the report though…
Calling the TFS Processor executable...
Fetching code coverage report information from TFS...
Attempting to locate a test results (.trx) file...
Looking for TRX files in: D:\agents\xxx\_work\231\TestResults, D:\agents\xxx\_work\231\s\TestResults
The following test results files were found: D:\agents\PC393-WS10-D\_work\231\s\TestResults\2024-11-15_16_20_45.trx
Absolute path to coverage file: D:\agents\xxx\_work\231\s\TestResults\2024-11-15_16_20_45\In\xxx\2024-11-15.16_21_07.coverage
The following code coverage attachments were found from the trx files: D:\agents\xxx\_work\231\s\TestResults\2024-11-15_16_20_45\In\xxx\2024-11-15.16_21_07.coverage
Not using the fallback mechanism to detect binary coverage files.
Cxxonverting coverage file 'D:\agents\x\_work\231\s\TestResults\2024-11-15_16_20_45\In\xxx\2024-11-15.16_21_07.coverage' to 'D:\agents\xxx\_work\231\s\TestResults\2024-11-15_16_20_45\In\x\2024-11-15.16_21_07.coveragexml'.
Coverage report conversion completed successfully.
The TFS Processor has finished
Calling the SonarScanner CLI...
I can confirm that the .coverage does have a non-0% code coverage.
So, okay. We do have code. But… It looks like the project is read as a test project:
> 2024-11-19T14:45:50.2864659Z 09:45:50.279 INFO: Sensor VB.NET Project Type Information [vbnet]
> 2024-11-19T14:45:50.2882334Z 09:45:50.279 DEBUG: Adding file type information (has MAIN 'false', has TEST 'true') for project 'MyApp.UnitTests' (project key 'DevMain-MyApp:DevMain-MyApp:C95CAC70-AE95-424B-A9E9-0227CAA51CC2', base dir 'D:\SomePath\318\s\Src\MyApp.UnitTests'). For debug info, see ProjectInfo.xml in 'D:\SomePath\318\.sonarqube\out\2'.
> 2024-11-19T14:45:50.2882846Z 09:45:50.279 INFO: Sensor VB.NET Project Type Information [vbnet] (done) | time=0ms
> 2024-11-19T14:45:50.2883005Z 09:45:50.279 INFO: Sensor VB.NET Analysis Log [vbnet]
> ```
And then we've got some generated code:
> ```
> 2024-11-19T14:45:50.2907454Z 09:45:50.279 DEBUG: Project 'DevMain-MyApp:DevMain-MyApp:C95CAC70-AE95-424B-A9E9-0227CAA51CC2': Analyzer working directory 'D:\SomePath\318\.sonarqube\out\2\output-vbnet' contains 6 .pb file(s)
> 2024-11-19T14:45:50.2928796Z 09:45:50.279 INFO: Roslyn version: 4.10.0.0
> 2024-11-19T14:45:50.2929248Z 09:45:50.279 INFO: Language version: VisualBasic16_9
> 2024-11-19T14:45:50.2929665Z 09:45:50.279 INFO: Concurrent execution: enabled
> 2024-11-19T14:45:50.2930775Z 09:45:50.279 DEBUG: File 'D:\SomePath\318\s\Src\MyApp.UnitTests\obj\Release\net8.0-windows\.NETCoreApp,Version=v8.0.AssemblyAttributes.vb' was recognized as generated
> 2024-11-19T14:45:50.2932152Z 09:45:50.279 DEBUG: File 'C:\Users\SomeUser\.nuget\packages\microsoft.net.test.sdk\17.8.0\build\netcoreapp3.1\Microsoft.NET.Test.Sdk.Program.vb' was recognized as generated
> ***Sensitive data REMOVED***
> 2024-11-19T14:45:50.2937062Z 09:45:50.279 INFO: Sensor VB.NET Analysis Log [vbnet] (done) | time=0ms
> ```
So I think we're back to having no "code" (only tests and generated files).
Ann