Our team has been creating, testing and refactoring our code, and as we do that we've been focusing on increasing code quality through unit testing. Passing tests turn coding into a game and as with any good game, you have to have your stats! Jenkins was already happily running our tests, but the boss was wondering if he could see our code coverage and test reports. How hard could that be to add? :)
I decided I'd dive into it to see if I could figure it out. It turns out
that once you know what you're doing, it's a pretty simple process. First off, you'll need to ensure you have all the right Jenkins plugins.
Then it's simply a matter of following plugin instructions. Our build follows this process.
- Build projects from source control using MS Build
- Clear the previous TestResults folder from the workspace with a batch command
- Run unit tests with VSTest.console
- Specify a settings file for .runsettings to exclude any assemblies you don't want to be shown in the coverage report
- Enable Code Coverage
- Run PowerShell Command for code coverage data conversion as described on the MS-Test plugin page.
- Post-build Action - Publish xUnit test result report
- Published as MSTest-Version N/A (default) Pattern
- Published as MSTest test result report
The end result is a series and graphs :)
|Project Overview Charts|
Jenkins is powerful, if not more than a little plugin happy... We are mainly a .NET shop at work, so while I feel Jenkins is a little disjointed. I'm imagining that if you're using it to build Java projects things may be slightly easier to configure. Nevertheless, the more familiar I get with it the more I'm liking it.