Code Coverage Metrics

From Anonymous on 2015/05/30 11:25:36 +0000

It’s very useful for developers to see test coverage for a project and its classes.

It’s very important for Product Owners and Project Managers to have access to this information without developer assistance so they can plan next stages of work, concentrate on deficient code or have an early warning system to begin asking questions or begin planning accordingly if test coverage starts to drop.

Other competing services such as Travis and Circle both implement support for Coveralls (and get Slather as a knock on benefit).

I propose Bitrise either builds in Coveralls and Slather support or rolls a Bitrise specific solution which takes advantage of the test coverage files delivered after an Xcode build.

Copied from original feature request: http://bitrise.uservoice.com/forums/235233-general/suggestions/8168802-code-coverage-metrics

From Vinayak Badrinathan on 2016/06/03 19:18:14 +0000

In case anyone else is looking for another way, here's what I did:

I enabled 'gather coverage data' under my test section in my scheme. I then added a lane in fastlane that does the following:

  • runs unit tests with the scheme mentioned above
  • invokes slather via the command line and captured stdout, stderr, and status via the gem Open3
  • added a regex that looks for the final test coverage results from slather's stdout output
  • if it's non-nil, the coverage number was parsed and we can write some logic to check that against the project's limit

Surely, the code in the gist can be cleaner, but it'll give you an idea of how you can add code coverage and a minimum threshold.

Example code: https://gist.github.com/vinnybad/efe32d7594ac7c1fe07bacffdb68b4ed

From Kyle McAlpine on 2016/01/12 14:34:48 +0000

I've written a bit about this on the Bitrise contrib repo here:

https://github.com/bitrise-io/bitrise-contrib/issues/3

It seems that Slather is not really being maintained anymore. Last commit was in October. So we're working on a replacement:

Goal is to output:

  • JSON
  • Cobertura
  • HTML

from the new Xcode Coverage.profdata code coverage file.

Contributors very much welcome :slight_smile:

From Bitrise on 2015/10/30 14:22:31 +0000

For this you now can use the Codecov step (https://github.com/bitrise-io/steps-codecov) which will generate and upload a code coverage report to Codecov (https://codecov.io). We haven't closed this idea, as we are curious what other related features you'd need.

Most of these things are possible now, the only thing which prevents you from easily checking the code coverage metrics of a build is: