SonarCloud code coverage failing on reading .xml summary file

Well after much reading and testing I found the solution to outputting both opencover and cobertura in my Azure and local Tests.

It was a random read the showed the using of the runsettings.xml to control the coverlet output. This simple xml file

<?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
	<DataCollectionRunSettings>
		<DataCollectors>
			<DataCollector friendlyName="XPlat code coverage">
				<Configuration>
					<Format>opencover,cobertura</Format>
				</Configuration>
			</DataCollector>
		</DataCollectors>
	</DataCollectionRunSettings>
</RunSettings>

Allowed me to change my Test command to:

dotnet test --collect:“XPlat Code Coverage” --settings runsettings.xml

In the Azure Test task and it works locally as well.

This outputs both of these files:
coverage.cobertura.xml
coverage.opencover.xml

1 Like