Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 尝试执行junit测试时出错_Java_Maven_Intellij Idea_Junit_Junit5 - Fatal编程技术网

Java 尝试执行junit测试时出错

Java 尝试执行junit测试时出错,java,maven,intellij-idea,junit,junit5,Java,Maven,Intellij Idea,Junit,Junit5,我试图运行一些junit测试,但我经常出错 Mypom.xml具有以下maven依赖项: <junit.version>4.12</junit.version> <junit.jupiter.version>5.0.1</junit.jupiter.version> <junit.vintage.version>${junit.version}.1</junit.vintage.version> <junit.plat

我试图运行一些junit测试,但我经常出错

My
pom.xml
具有以下maven依赖项:

<junit.version>4.12</junit.version>
<junit.jupiter.version>5.0.1</junit.jupiter.version>
<junit.vintage.version>${junit.version}.1</junit.vintage.version>
<junit.platform.version>1.0.1</junit.platform.version>

<!-- junit dependencies -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${junit.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>${junit.jupiter.version}</version>
        <scope>test</scope>
    </dependency>
    <!-- Only required to run tests in an IDE that bundles an older version -->
    <dependency>
        <groupId>org.junit.platform</groupId>
        <artifactId>junit-platform-launcher</artifactId>
        <version>${junit.platform.version}</version>
        <scope>test</scope>
    </dependency>
    <!-- Only required to run tests in an IDE that bundles an older version -->
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>${junit.jupiter.version}</version>
        <scope>test</scope>
    </dependency>
    <!-- Only required to run tests in an IDE that bundles an older version -->
    <dependency>
        <groupId>org.junit.vintage</groupId>
        <artifactId>junit-vintage-engine</artifactId>
        <version>${junit.vintage.version}</version>
        <scope>test</scope>
    </dependency>
    <!-- To avoid compiler warnings about @API annotations in JUnit code -->
    <dependency>
        <groupId>org.apiguardian</groupId>
        <artifactId>apiguardian-api</artifactId>
        <version>1.0.0</version>
        <scope>test</scope>
    </dependency>
我正在使用IntelliJ IDEA 2016.3.5


我在谷歌上搜索了一下,但没有找到任何好的回复,没有任何想法?

我已经从您提供的链接下载了该项目。当我将
add
方法更改为
public
时,一切正常:

@Test
public void add() {
    Calculator calculator = new Calculator();
    assertEquals(2, calculator.add(1, 1), "1 + 1 should equal 2");
}
我尝试从IDE和maven运行测试。要从maven运行测试,您可以尝试在命令行中执行以下命令:

mvn clean install
这将为您构建项目并运行测试

我的设置是:

  • Java版本:“1.8.0_131”
  • Maven版本:3.3.9
  • IntelliJ idea版本(如果您想从IDE运行测试,可能会很有用):2017.2.5

我已从您提供的链接下载了该项目。当我将
add
方法更改为
public
时,一切正常:

@Test
public void add() {
    Calculator calculator = new Calculator();
    assertEquals(2, calculator.add(1, 1), "1 + 1 should equal 2");
}
我尝试从IDE和maven运行测试。要从maven运行测试,您可以尝试在命令行中执行以下命令:

mvn clean install
这将为您构建项目并运行测试

我的设置是:

  • Java版本:“1.8.0_131”
  • Maven版本:3.3.9
  • IntelliJ idea版本(如果您想从IDE运行测试,可能会很有用):2017.2.5

能否在GitHub上提供示例项目,以便更容易地找出问题所在?我创建此示例是为了复制错误。能否在GitHub上提供示例项目,以便更容易地找出问题所在?我创建此示例项目是为了复制错误。看起来像是将我的IntelliJ idea版本升级到2017.2.5版本这个问题。非常感谢。看来将IntelliJ idea版本升级到2017.2.5可以解决这个问题。非常感谢。