I recently set up Travis CI integration for YAGP YAGP. This included both the build and NUnit testing for the SharpGedParser project.
Next I wanted test coverage results integration with Coveralls - namely to show as a badge on Github. With some fumbling and dead-end research, I did get this working with Minicover.
At some point, minicover shipped coveralls reporting and this fact doesn't seem to have percolated to the rest of the web yet.
The end result is pretty simple and I hoped you might avoid some wasted research if I wrote it up here.
- The first step is get your build working with Travis and sign up with Coveralls.
- Read the minicover README and a blog entry at Automation Rhapsody. These were a big step forward for me getting this to work.
- Create a minicover project in your solution. This project has no code, only a reference to minicover. This is the recommended approach and allows 'dotnet restore' to fetch minicover automagically. See the blog above.
-
In your travis.yml, use minicover to instrument the dll(s) under test, and point minicover at the pertinent sources. I have also excluded the test sources to remove them from the coverage stats.
Note the current directory structure is as follows:
root: TravisCore.sln +minicover minicover.csproj +TravisParse TravisParse.csproj
Here is the relevant YML for YAGP:
script: # Build the solution! - dotnet build # Minicover project below current working directory - cd minicover # my tests are currently merged in with the code; you # might have a separate test assembly. Note the # exclusion of the test sources from coverage. - dotnet minicover instrument --workdir ../ --assemblies TravisParse/**/bin/**/TravisParse.dll --sources SharpGedParse/SharpGedParser/**/*.cs --exclude-sources SharpGedParse/SharpGedParser/**/Tests/*.cs - dotnet minicover reset - cd .. # Run the tests! - dotnet test --no-build ./TravisParse/TravisParse.csproj
-
Use minicover to report results to Coveralls!
Here is the relevant YML for YAGP:
script: ... # Run the tests! - dotnet test --no-build ./TravisParse/TravisParse.csproj - cd minicover # report coverage results to Coveralls! - dotnet minicover coverallsreport --root-path ../ --workdir ../ --service-name "travis-ci" --service-job-id "$TRAVIS_JOB_ID"