Mistu4u
Mistu4u

Reputation: 5416

Run as Junit5 is missing in Eclipse

Below is my 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>

Below is my test case:

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);
  }
}

I am not getting the option to run as JUnit 5 in Eclipse. I am using Eclipse Neon. When trying to use "Junit" from Run configuration, it is not able to find the test class.

enter image description here

When trying to select the test class, getting error, " Cannot find class 'junit.framework.TestCase' on project build path"

enter image description here

And the Maven dependencies are in build path:

enter image description here

What is going wrong here?

Upvotes: 1

Views: 1079

Answers (1)

nitind
nitind

Reputation: 20003

JUnit 5 came out in late 2017. The last maintenance release for Neon was early 2017. Upgrade to Photon.

Upvotes: 1

Related Questions