有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java代码覆盖率遗漏了关于测试异常的说明

   @Test
   public void testNullPointerException() {
      thrown = false;
      IntList list = null;
      IntList sublist = new IntList(null);
      IntList newList = new IntList(2, 2, 4);
      try {
         actual = OrderedIntListUtility.replaceAll(list, sublist, newList);
      } catch(NullPointerException e) {
         thrown = true;
      }
   }

Java代码覆盖率表明我在这个特定测试中遗漏了一些指令。我不知道这里遗漏的说明在哪里。请帮忙。谢谢


共 (1) 个答案

  1. # 1 楼答案

    来自eclemma文档http://www.eclemma.org/jacoco/trunk/doc/counters.html

    Instructions (C0 Coverage) - The smallest unit JaCoCo counts are single Java byte code instructions. Instruction coverage   
    provides information about the amount of code that has been executed or missed. This metric is 
    completely independent from source formatting and always available, even in absence of debug 
    information in the class files.