Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I fail a TeamCity build if dotCover doesn't report a high enough result?

I would like TeamCity to run my mSpec tests and report on the code covered by the tests.

I would also like TeamCity to report that a build has failed if code coverage in certain namespaces doesn't meet a threshold (e.g. MyProduct.ImportantStuff must be 100%, but MyProduct.LegacyStuff must be [23% or whatever it currently is to ensure we don't add new stuff without covering tests].

I initially looked at dotCover as it's integrated into TeamCity. I have since been looking at OpenCover as I couldn't get TC to fail the build on low coverage.

I got OpenCover working but I would still like to know (as I'm sure a lot of people would) how to get TC to fail a build if code coverage is too low.

like image 297
Steve Dunn Avatar asked Apr 24 '12 11:04

Steve Dunn


1 Answers

Are you using the latest TeamCity, ie version 7?

When setting up a build configuration you can specify this:

enter image description here

There are lots more options in the dropdown related to code coverage. You can also force your build to fail if you're using some other code coverage tool. For example you can echo a line to the console that will then be picked up by teamcity :

##teamcity[buildStatus status='FAILURE' text='something failed']

see official docs on this here

like image 135
wal Avatar answered Sep 19 '22 17:09

wal