我想在Eclipse中运行JUnit测试。我尝试过:
我添加了POM依赖项:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.1.0</version>
<scope>test</scope>
</dependency>
JUnit测试
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() {
}
}
但是当我运行测试时,我得到了:
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
您能给我一些错误之处以及如何解决此问题的建议吗?
答案 0 :(得分:2)
摆脱@RunWith(JUnitPlatform.class)
,这是JUnit 4运行Jupiter测试的方式。有了Eclipse中的JUnit 5平台支持,您将不再需要它。