Currently, JUnit 5 is just out with a \"stable\" version. IntelliJ supports JUnit 5 according to the Website. My question is if eclipse is supporting JUnit 5 as well, and if not
With Eclipse Kepler Service Release 2
, you can run JUnit 5
tests after annotating the class with @RunWith(JUnitPlatform.class)
as follows:
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.platform.runner.JUnitPlatform;
import org.junit.runner.RunWith;
@RunWith(JUnitPlatform.class)
public class Junit5Demo {
@DisplayName("First Test")
@Test
void firstTest() {
assertEquals(1, 1);
}
}
pom.xml
of the project is as follows:
4.0.0
arpit.aggarwal.junit5.demo
junit5-demo
0.0.1-SNAPSHOT
UTF-8
1.8
5.0.0-M2
4.12.0-M2
1.0.0-M2
maven-compiler-plugin
3.1
${java.version}
maven-surefire-plugin
2.19.1
**/Test*.java
**/*Test.java
**/*Tests.java
**/*TestCase.java
org.junit.platform
junit-platform-surefire-provider
${junit.platform.version}
org.junit.jupiter
junit-jupiter-engine
${junit.jupiter.version}
test
org.junit.vintage
junit-vintage-engine
${junit.vintage.version}
test
org.junit.platform
junit-platform-runner
${junit.platform.version}
test