One hurdle was that Jenkins seems to need to be run as user with administrator rights in order for OpenCover to work. So I created one and assigned it in the "Log On" tab.
In my Jenkins job, I opened "Add build step" and selected "Execute Windows batch command". In there, I gave the command line:
"C:\Program Files (x86)\OpenCover\OpenCover.Console.exe" -target:"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\mstest.exe" -targetargs:"/testcontainer:E:\Jenkins\jobs\BuildOurApp\workspace\TRUNK\OurApp.UnitTests\bin\release\OurApp.UnitTests.dll" -filter:"+[OurApp.AssemblyToCover1]* +[OurApp.AssemblyToCover2]*" -register:user -mergebyhash -output:E:\Jenkins\jobs\BuildOurApp\workspace\FilteredCodeCoverage.xml
As an aside, I often have Jenkins jobs with several batch command sections. I found it annoying to scroll up and down and quickly find the one I was looking to edit. So I've started marking the top of each script:
REM _ ___ _ __ _____ REM | | |_ _|| |/ /| ____| REM | | | | | ' / | _| REM | |___ | | | . \ | |___ REM |_____||___||_|\_\|_____| REM REM _____ _ _ ___ ____ REM |_ _|| | | ||_ _|/ ___| REM | | | |_| | | | \___ \ REM | | | _ | | | ___) | REM |_| |_| |_||___||____/
( http://patorjk.com/software/taag/ , "Standard" font, unchecked "Smush Letters Together" )
I have the HTML Publisher plugin installed, so I enabled it, clicked Add to add a row and specified:
E:\Jenkins\jobs\BuildOurApp\FilteredCodeCoverageReport
index.htm
Code Coverage Report
as the arguments and it's all set! Now coverage is computed automatically and my team has a single URL for a summary report with drill-down details.
No comments:
Post a Comment