We’re analyzing code coverage on Azure Pipelines, with the VSTest task create a .coverage file. Looking at the logs, Sonarscanner then uses the codecoverage.exe to convert the file to xml which reports no errors. See below:
2020-01-15T08:03:39.0953044Z 08:03:39.077 The following code coverage attachments were found from the trx files: d:\a\1\s\TestResults\VssAdministrator_fv-az28_2020-01-15_08_03_06\In\fv-az28\VssAdministrator_fv-az28 2020-01-15 08_02_43.coverage
2020-01-15T08:03:39.0953376Z 08:03:39.077 Not using the fallback mechanism to detect binary coverage files.
2020-01-15T08:03:39.1075579Z 08:03:39.093 Executing file C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
2020-01-15T08:03:39.1076197Z Args: analyze /output:d:\a\1\s\TestResults\VssAdministrator_fv-az28_2020-01-15_08_03_06\In\fv-az28\VssAdministrator_fv-az28 2020-01-15 08_02_43.coveragexml d:\a\1\s\TestResults\VssAdministrator_fv-az28_2020-01-15_08_03_06\In\fv-az28\VssAdministrator_fv-az28 2020-01-15 08_02_43.coverage
2020-01-15T08:03:39.1077531Z Working directory: d:\a\1\s\TestResults\VssAdministrator_fv-az28_2020-01-15_08_03_06\In\fv-az28
2020-01-15T08:03:39.1077758Z Timeout (ms):60000
2020-01-15T08:03:39.1077962Z Process id: 4224
2020-01-15T08:03:41.1948132Z 08:03:41.191 Process returned exit code 0
2020-01-15T08:03:41.2270324Z Generating SonarQube project properties file to d:\a\1.sonarqube\out\sonar-project.properties
2020-01-15T08:03:41.2621049Z Setting analysis property: sonar.visualstudio.enable=false
However, after the job is almost complete, the scanner tries to parse the .coverage file rather than the .coveragexml file and then fails. Resulting in no code coverage being uploaded:
2020-01-15T08:04:41.9188498Z 08:04:41.193 INFO: Parsing the Visual Studio coverage XML report d:\a\1\s\TestResults\VssAdministrator_fv-az28_2020-01-15_08_03_06\In\fv-az28\VssAdministrator_fv-az28 2020-01-15 08_02_43.coverage
2020-01-15T08:04:41.9189509Z 08:04:41.208 WARN: Unable to get next XML event while parsing file ‘d:\a\1\s\TestResults\VssAdministrator_fv-az28_2020-01-15_08_03_06\In\fv-az28\VssAdministrator_fv-az28 2020-01-15 08_02_43.coverage’
2020-01-15T08:04:41.9196373Z 08:04:41.208 WARN: Could not import coverage report ‘d:\a\1\s\TestResults\VssAdministrator_fv-az28_2020-01-15_08_03_06\In\fv-az28\VssAdministrator_fv-az28 2020-01-15 08_02_43.coverage’ because ‘Error while parsing the XML file: d:\a\1\s\TestResults\VssAdministrator_fv-az28_2020-01-15_08_03_06\In\fv-az28\VssAdministrator_fv-az28 2020-01-15 08_02_43.coverage’
2020-01-15T08:04:41.9201017Z 08:04:41.208 DEBUG: The current user dir is ‘d:\a\1’.
2020-01-15T08:04:41.9201957Z 08:04:41.208 INFO: Parsing the Visual Studio coverage XML report d:\a\1\s\TestResults\dbef655a-6461-4635-8bd5-5bd0ebd33a5a\VssAdministrator_fv-az28 2020-01-15 08_02_43.coverage
2020-01-15T08:04:41.9202423Z 08:04:41.208 WARN: Unable to get next XML event while parsing file ‘d:\a\1\s\TestResults\dbef655a-6461-4635-8bd5-5bd0ebd33a5a\VssAdministrator_fv-az28 2020-01-15 08_02_43.coverage’
2020-01-15T08:04:41.9202907Z 08:04:41.208 WARN: Could not import coverage report ‘d:\a\1\s\TestResults\dbef655a-6461-4635-8bd5-5bd0ebd33a5a\VssAdministrator_fv-az28 2020-01-15 08_02_43.coverage’ because ‘Error while parsing the XML file: d:\a\1\s\TestResults\dbef655a-6461-4635-8bd5-5bd0ebd33a5a\VssAdministrator_fv-az28 2020-01-15 08_02_43.coverage’
2020-01-15T08:04:41.9203341Z 08:04:41.208 DEBUG: Analyzing coverage after aggregate found ‘0’ coverage files.
2020-01-15T08:04:41.9203697Z 08:04:41.208 DEBUG: The total number of file count statistics is ‘0’.
2020-01-15T08:04:41.9204071Z 08:04:41.208 INFO: Sensor C# Tests Coverage Report Import [csharp] (done) | time=15ms
2020-01-15T08:04:41.9204440Z 08:04:41.208 INFO: Sensor C# Unit Test Results Import [csharp]
Using properties:
sonar.cs.nunit.reportsPaths=$(System.DefaultWorkingDirectory)\TestResults**.trx,
sonar.cs.vscoveragexml.reportsPaths=$(System.DefaultWorkingDirectory)\TestResults**.coverage
Once the conversion has taken place, should the scanner not be referencing the xml files rather than trying to read the .codecoverage binary file?