A successful JUnit coverage test doesn't turn green on methods that test exceptions
Asked Answered
A

1

5

I have a small JUnit test that expects an exception to be thrown. The method throws the exception as expected but when I'm running a "Coverage As" run in Eclipse SpringSource ToolSuite, the two lines in the test method stay red instead of turning green. This test passes--no issues there.

The mockPropertyReader is an empty Properties file reader class. I'm simply testing for the exception if the property is malformed or doesn't exist.

I'm just thinking the method lines should be highlighted to green. I like lots of green.

@Test(expected = PropertyNotFoundException.class)
public final void testGetMySQLNotFound() throws PropertyNotFoundException {
    subject.setSqlProps(mockPropertyReader);
    subject.getMySQL();
}
Addia answered 6/12, 2012 at 16:31 Comment(0)
N
7

This is a known issue with Emma.

http://www.eclemma.org/faq.html#trouble05

Natale answered 6/12, 2012 at 16:39 Comment(1)
Thanks... I'm ok with things generally, if I can know the reason. Thanks again. I'm devoted to adding Junit testing to all my applications. It's a personal goal more than a corporate goal, so it's up to me to figure out it all.Addia

© 2022 - 2024 — McMap. All rights reserved.