Peter Penzov
Peter Penzov

Reputation: 1648

How to run JUnit 5 tests in Eclipse

I want to run JUnit test in Eclipse. I tried this:

I added POM dependency:

    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.1.0</version>
        <scope>test</scope>
    </dependency>

JUnit test

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.platform.runner.JUnitPlatform;
import org.junit.runner.RunWith;

@RunWith(JUnitPlatform.class)
public class DatabaseFeaturesTest {

    @Test
    public void writeData() {
        System.out.println("Converting Map using bitmasking");
    }

    @AfterAll
    public void databaseInsert() {

    }
}

But when I run the test I get:

Aug 24, 2018 12:29:23 PM org.junit.vintage.engine.discovery.DefensiveAllDefaultPossibilitiesBuilder$DefensiveAnnotatedBuilder buildRunner
WARNING: Ignoring test class using JUnitPlatform runner: org.rest.api.DatabaseFeaturesTest
Aug 24, 2018 12:29:23 PM org.junit.vintage.engine.discovery.DefensiveAllDefaultPossibilitiesBuilder$DefensiveAnnotatedBuilder buildRunner
WARNING: Ignoring test class using JUnitPlatform runner: org.rest.api.DatabaseFeaturesTest

Can you give some advice where I'm wrong and how to fix the issue?

Upvotes: 2

Views: 5886

Answers (1)

johanneslink
johanneslink

Reputation: 5341

Get rid of @RunWith(JUnitPlatform.class) which is JUnit 4‘s way to run Jupiter tests. With JUnit 5 platform support in Eclipse you no longer need it.

Upvotes: 6

Related Questions