Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

JUnit @Rule ExpectedException marked as failure


In the Clover HTML output, Clover marks JUnit tests that use the new JUnit @Rule ExpectedException to check for exceptions as failures, even though the test actually passes. I found this on the documentation: however, the comment on it is not clear to me:

Clover does its best to record your test results in the Clover database. In some instances however, Clover can not always do so. Although unit tests using@Test(expected=Exception.class) annotations will be marked as passed, more novel JUnit constructs such as rules may not be recognized and Clover will flag those tests as failed when in fact they passed. To integrate these test results into your Clover reports follow these steps:

Does this mean that this is a known issue that can/will never be fixed, or will there eventually be some fix?


4 answers

1 accepted

0 votes
Answer accepted
mstudman Atlassian Team Dec 19, 2011

Yes, this is a known issue. Unfortunately it's fairly infeasible for us to fix hence you will need to follow the workaround to get correct test results integrated into your Clover report.

While it may be infeasible to fix all @Rule classes, shouldn't it be possible to develop a solution for something as common and helpful as the ExpectedException rule?

I'm suffering from the same problem. ExpectedException rule is ignored and tests marked as failed even though they pass. I don't want to change 350 unit test . I'm trying to find a workaround but no success so far. I'm using Maven, please help!

Note: I'd be satisfied with just being able to say "includeFailedTestCoverage" in maven plugin.

Dear, Is this issue still existing or has been resolved?

I am also facing this issue!!


Is there any update on this issue?

As an option to workaround this is to change all tests from @Rule to @Test(expected=MyException.class)? Is there any other way to approach it?

Hi Oleksii,

Can't say if there are any solutions, but I'd like to note that migrating your tests from `ExpectedException` rule to `expected` parameter of `Test` annotation is not a good one:

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Marketplace Apps & Integrations

Happy New Year and Welcome New Marketplace Partner Program Partners!

Happy New Year! We hope you all had a safe and restful holiday season. 2020 was a unique year full of unforeseen events; however, as we enter the new year of 2021, we’re optimistic for the light at t...

536 views 7 20
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you