Saturday, January 3, 2015

Preventing build failure for muted tests in TeamCity

If you are using Maven to run your JVM project and tests and you are using TeamCity at the same time, you might run to a similar problem as we did. There is a cool feature in TeamCity, ability to mute tests. This means that you can mark a test as muted and then if this test fails, the whole build status will still be a success.

But not if you are using a Maven + TeamCity combination. There is a bug in TeamCity reported in 2011 and even though in this thread a TeamCity developer marked the issue as major problem and promised to fix it ASAP, it still did not happen.

Fortunately, there is a solution hidden in the comments at the bug report. If you want this to work, you need to take advantage of the Surefire maven plugin configuration setting - testFailureIgnore. What it does is that the build will not fail if a test fails. But that is not something you want for your regular maven build. So you definitely should not update your maven pom.xml with this option because for your non-TeamCity builds your probably still want the build to fail if the test fails. That’s why your should take advantage of the Additional Maven command line parameters of your maven build step and run Maven with additional parameter -Dmaven.test.failure.ignore=true

With this thing set up, you just need to make sure that in your build configuration settings you have the at least one test failed checked. With TeamCity set up as this, Maven will ignore the test failures, but the TeamCity will still parse the SureFire output report and fail the build step if a test (that is not muted) fails.

3 comments:

  1. Thanks for writing in such an encouraging post. I had a glimpse of it and couldn’t stop reading till I finished. I have already bookmarked you. hotel management colleges in punjab

    ReplyDelete
  2. I simply want to tell you that I am new to weblog and definitely liked this blog site. Very likely I’m going to bookmark your blog . You absolutely have wonderful stories. Cheers for sharing with us your blog.
    you should also visit this for more astounding info Solution Case Study

    ReplyDelete
  3. Actuary Finance Assignment Help
    Actuary Assignment Help, Actuarial science assignment help in the actuarial field of science from primary to complex level for the understudies of US UK.

    ReplyDelete