Code coverage in Java with EclEmma not scanning expecting exception methods

后端 未结 3 1403
滥情空心
滥情空心 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条回答
  •  梦毁少年i
    2021-01-04 01:09

    No, there is no way to get EclEmma to notice the expected clause. They acknowledge this fact here.

    Why are JUnit4 test cases with expected exceptions shown as not covered?

    JUnit4 test cases with expected exceptions are shown as not covered even though they were executed. The reason for this is that underlying JaCoCo code coverage library only considers code as executed when certain probes are executed. For successful test cases marked with @Test{expected=...} this is not the case.

    Personally, I wouldn't worry too much about it. Coverage of test cases is the least interesting thing EclEmma can tell you; I always completely ignore those metrics and focus on the coverage of my production code.

提交回复
热议问题