Skip to content

Instantly share code, notes, and snippets.

@martea
Created April 24, 2017 18:13
Show Gist options
  • Save martea/2dc5931bd6ebc7185d5d5b731829aa55 to your computer and use it in GitHub Desktop.
Save martea/2dc5931bd6ebc7185d5d5b731829aa55 to your computer and use it in GitHub Desktop.
CodeCoverage
  1. Install https://github.com/OpenCover/opencover/releases/download/4.6.519/opencover.4.6.519.msi \OpenCover

  2. Install https://github.com/nunit/nunit-console/releases/download/3.6.1/NUnit.Console-3.6.1.msi \NUnit

  3. Install https://github.com/danielpalme/ReportGenerator/releases/download/v2.5.6.0/ReportGenerator_2.5.6.0.zip \ReportGenerator

  4. mkdir \Coverage\report

  5. mkdir \Coverage\history

  6. Spara följande i \OpenCover\cov.bat

  7. open "Developer Command Prompt for VS2015"

  8. navigate to \OpenCover\

  9. Kör codecov.bat <sökväg till root mapp>

Note that report will be cleaned after each runtime.

@echo off
if "%1"=="" goto missingarg
set BASEDIR=%1
if %BASEDIR:~-1%==\ set BASEDIR=%BASEDIR:~0, -1%
for %%f in (%BASEDIR%) do set BRANCHDIR=%%~nxf
echo Using branch: %BRANCHDIR%
msbuild %BASEDIR%\Asfinag.DiVi.sln
if %ERRORLEVEL% neq 0 goto builderror
OpenCover.Console.exe -target:"<working dir>\NUnit\nunit-console\nunit3-console.exe" -targetargs:"--result=..\Coverage\%BRANCHDIR%_core_test.xml --where:cat!=Integration %BASEDIR%\<Path to DLL to codecoverage>" -output:..\Coverage\%BRANCHDIR%_core_coverage.xml -register:user -filter:"+[*]* -[*.*Test*]*" -excludebyattribute:"System.CodeDom.Compiler.GeneratedCodeAttribute;System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" -hideskipped:all
rmdir ..\Coverage\report /S /q
..\ReportGenerator\ReportGenerator.exe -reports:..\Coverage\%BRANCHDIR%_coverage.xml; -targetdir:..\Coverage\report\ -historydir:..\Coverage\history -assemblyfilters:+*<assembly name>*
start "" ..\Coverage\report\index.htm
goto done
:missingarg
echo Use: %0 pathtobranch
goto done
:builderror
echo Faild to build solution
goto done
:done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment