From 0d69b5ee62bbed8002e37fab2f4edf4cdfdfe704 Mon Sep 17 00:00:00 2001 From: lukeIam <2lukeiam@gmail.com> Date: Tue, 1 May 2018 15:20:42 +0200 Subject: [PATCH] Use OpenCover to generate coverage statistics for SonarSloud --- appveyor.yml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index ed3f417b..dc0f01e2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -33,7 +33,8 @@ install: } else{ $Env:TAG_NAME_WITH_BRANCH_NAME_FALLBACK = $Env:APPVEYOR_REPO_BRANCH - } + } + choco install "opencover.portable" -y before_build: - ps: | Try @@ -63,14 +64,15 @@ before_build: /d:"sonar.pullrequest.branch=$env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH" } elseif($Env:APPVEYOR_REPO_BRANCH -eq 'develop'){ - choco install "msbuild-sonarqube-runner" -y + choco install "msbuild-sonarqube-runner" -y SonarScanner.MSBuild.exe begin ` /k:"lukeIam_Vocaluxe" ` /d:sonar.organization="lukeiam-github" ` /d:sonar.host.url="https://sonarcloud.io" ` /v:"$Env:GIT_VERSION_TAG" ` /d:sonar.login="$Env:SonarQubeToken" ` - /d:sonar.cs.nunit.reportsPaths="$env:APPVEYOR_BUILD_FOLDER\TestResult.xml" + /d:sonar.cs.nunit.reportsPaths=".\TestResult.xml" ` + /d:sonar.cs.opencover.reportsPaths=".\CoverageResult.xml" } } build: @@ -107,6 +109,17 @@ after_build: .\.appveyor\nightlyDetect.ps1 .\.appveyor\moveTagForSpecialBranches.ps1 } +test_script: +- ps: | + if ($Env:PLATFORM -eq 'x64' -and ($Env:APPVEYOR_PULL_REQUEST_NUMBER -or $Env:APPVEYOR_REPO_BRANCH -eq 'develop')){ + OpenCover.Console.exe -register:user -target:"nunit3-console.exe" -targetargs:".\Tests\bin\Release\Tests.dll --result=.\TestResult.xml;format=AppVeyor" -output:".\CoverageResult.xml" + } + else{ + nunit3-console.exe ".\Tests\bin\Release\Tests.dll" --result=".\TestResult.xml;format=AppVeyor" + } + $wc = New-Object 'System.Net.WebClient' + $wc.UploadFile("https://ci.appveyor.com/api/testresults/nunit3/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\TestResult.xml)) + after_test: - ps: | if ($Env:PLATFORM -eq 'x64' -and ($Env:APPVEYOR_PULL_REQUEST_NUMBER -or $Env:APPVEYOR_REPO_BRANCH -eq 'develop')){