Created
March 25, 2019 16:07
-
-
Save ThiagoBarradas/d59ee9a2dbb4c2b5ce5b96562dc97725 to your computer and use it in GitHub Desktop.
Sonarqube - send dotnet code analysis and code coverage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install sonarqube scanner / reporter | |
dotnet tool install --global dotnet-sonarscanner | |
# Install dotnet tools to generate test report | |
dotnet tool install --global coverlet.console | |
dotnet add package coverlet.msbuild | |
# Start sonarqube process | |
dotnet build-server shutdown | |
dotnet sonarscanner begin /o:${SONAR_ORG_KEY} /k:${SONAR_PROJECT_KEY} /v:${VERSION} /d:sonar.host.url=https://sonarcloud.io /d:sonar.login=${SONAR_TOKEN} /d:sonar.cs.opencover.reportsPaths="opencover.xml" | |
# Build solution | |
dotnet restore | |
dotnet build ./MySolution.sln | |
# Running unit tests - 'opencover ' output format | |
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=coverage /p:Exclude=[xunit.*]* ./MySolution.sln | |
mv ./MyProject.Tests/coverage.opencover.xml opencover.xml | |
# Send test report result to codeclimate | |
dotnet sonarscanner end /d:sonar.login=${SONAR_TOKEN} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What if you have more than one test project? How do you do
?