I have setup the sonarQube for my c# project. In sonarQube server I can see the other analysis but I cannot see the code coverage. I see many documents but didn’t solve the problem. I have already followed the documents from sonarQube but didn’t helped.
here is what I am doing:
In my azure pipeline I am preparing the analysis on sonarQube then building my solution then i am running a power shell script for running tests and then to create a xml file with coverage (which is working fine and showing me results).
after that I am also running code analysis and publish Quality Gate result.
Can you please give me in detail steps for .NET framework and C# projects SonarQube analysis which includes code coverage steps? or any other suggestions
para proyectos dot net core puedes intentar lo siguiente:
1.- abre el proyecto con VS o dando doble click en el archivo .sln e instala el plugin coverlet.msbuild desde el NuGet en tu proyecto de pruebas.
2.- Abre la terminal Develop Comand Pront, en la raíz del proyecto ejecuta el siguiente script:
cd C:\ruta completa de tu solución
dotnet build-server shutdown
DEL .\TestResults /S /Q
dotnet tool install --global dotnet-sonarscanner > nul
dotnet tool install --global dotnet-reportgenerator-globaltool > nul
dotnet sonarScanner begin /k:“llaveDeTuProyeto” /d:sonar.language=“cs” /d:sonar.cs.opencover.reportsPaths="%CD%\TestResults\coverage.opencover.xml" /d:sonar.exclusions="/bin//,/obj//,/Migrations/" /d:sonar.coverage.exclusions=“test/**”
dotnet restore archivoSolucion.sln
dotnet build archivoSolucion.sln
dotnet test archivoSolucion.sln /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput="%CD%/TestResults/"
reportgenerator -reports:"%CD%/TestResults/*.xml" -targetdir:./TestResults/Reports/ -reportTypes:“HTML;HTMLInline;Cobertura”
dotnet sonarscanner end