我已经用java8 defult方法声明了我的接口:

public interface MyInterface {

    default String myMethod(String str) {
        //IMPLEMENTATION
    }
}


接下来,我执行了Maven目标:

mvn cobertura:cobertura


该日志显示错误,因为cobertura不支持java8默认方法声明:

[INFO] Executed tasks
[INFO]
[INFO] <<< cobertura-maven-plugin:2.7:cobertura (default-cli) < [cobertura]test @ extractor <<<
[INFO]
[INFO] --- cobertura-maven-plugin:2.7:cobertura (default-cli) @ extractor ---
[INFO] Cobertura 2.1.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
[INFO] Cobertura: Loaded information on 134 classes.
[WARN] JavaNCSS got an error while parsing the java file <PATH_TO_MY_INTERFACE>\MyInterface.java
ParseException in STDIN
Last useful checkpoint: "path.to.my.class.MyInterface"
Encountered " "default" "default "" at line 10, column 9.
Was expecting one of:
    "abstract" ...
    "boolean" ...
    "byte" ...
    "char" ...
    "class" ...
    "double" ...
    "enum" ...
    "final" ...
    "float" ...
    "int" ...
    "interface" ...
    "long" ...
    "native" ...
    "private" ...
    "protected" ...
    "public" ...
    "short" ...
    "static" ...
    "strictfp" ...
    "synchronized" ...
    "transient" ...
    "void" ...
    "volatile" ...
    <IDENTIFIER> ...
    "}" ...
    ";" ...
    "@" ...
    "<" ...


我该如何解决?

最佳答案

我已更改为JaCoCo Maven配置,并且可以正常工作。

JaCoCo Unit Tests + Reports

07-24 21:24