Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.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 Eclipse中缺少Junit5时运行_Java_Eclipse_Junit - Fatal编程技术网

Java Eclipse中缺少Junit5时运行

Java Eclipse中缺少Junit5时运行,java,eclipse,junit,Java,Eclipse,Junit,下面是我的pom.xml: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache

下面是我的pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.myapp</groupId>
<artifactId>backend</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.1.RELEASE</version>
</parent>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.8.2</version>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>5.2.0</version>
    </dependency>
</dependencies>
我没有在Eclipse中作为JUnit5运行的选项。我正在使用Eclipse霓虹灯。当试图从运行配置中使用“Junit”时,它无法找到测试类

尝试选择测试类时,出现错误,“在项目生成路径上找不到类'junit.framework.TestCase'”

Maven依赖项位于构建路径中:


这里出了什么问题?

JUnit 5于2017年底推出。Neon的最后一次维护发布是2017年初。升级到光子

package com.myapp.backend;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

class DistanceCalculatorTest {
@Test
public void smokeTest() {
    Location placeABC = new Location(41.3925603, 2.1418532);
    Location placaBCD = new Location(41.3870194,2.1678584);

    // More or less 2km 
    assertEquals(2.0, DistanceCalculator.calculateDistance(placeABC , placaBCD ), 0.5);
  }
}