Code coverage in Java with EclEmma not scanning expecting exception methods

后端 未结 3 1423
滥情空心
滥情空心 2021-01-04 00:39

I\'m trying to get my code coverage in java, using Eclipse and EclEmma.

My tests are using JUnit 4 and I\'ve got some tests looking like this :

    @         


        
3条回答
  •  孤独总比滥情好
    2021-01-04 01:03

    Can't comment yet, but I wanted to point out, in relation to the accepted answer, that there's a very good reason to pay attention to coverage of your test code.

    It's just way to easy with JUnit to screw up the test method naming convention or forget the @Test annotation, depending on your JUnit version. Do that, and you could easily be fooled into thinking that your solid green bar means that the nice test you just added passed, when in fact it never ran. Coverage coloring will show this very prominently. Except of course, as this thread points out, some of your tests that throw exceptions might look like they didn't run when they did.

提交回复
热议问题