Maven not running JUnit 5 tests
Im trying to get a simple junit test running with maven but it is not detecting any tests. Where am I going wrong? The project directory
Project -> src -> test-> java -> MyTest.java
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
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.buildproftest.ecs</groupId>
<artifactId>buildprofiletest</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.3.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<debug>false</debug>
<optimize>true</optimize>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Junit test case
import org.junit.jupiter.api.Test;
public class MyTest {
@Test
public void printTest() {
System.out.println("Running JUNIT test");
}
}
The response is that there are no test cases to run.
Thanks for your insight
maven junit maven-surefire-plugin junit5
add a comment |
Im trying to get a simple junit test running with maven but it is not detecting any tests. Where am I going wrong? The project directory
Project -> src -> test-> java -> MyTest.java
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
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.buildproftest.ecs</groupId>
<artifactId>buildprofiletest</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.3.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<debug>false</debug>
<optimize>true</optimize>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Junit test case
import org.junit.jupiter.api.Test;
public class MyTest {
@Test
public void printTest() {
System.out.println("Running JUNIT test");
}
}
The response is that there are no test cases to run.
Thanks for your insight
maven junit maven-surefire-plugin junit5
add a comment |
Im trying to get a simple junit test running with maven but it is not detecting any tests. Where am I going wrong? The project directory
Project -> src -> test-> java -> MyTest.java
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
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.buildproftest.ecs</groupId>
<artifactId>buildprofiletest</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.3.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<debug>false</debug>
<optimize>true</optimize>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Junit test case
import org.junit.jupiter.api.Test;
public class MyTest {
@Test
public void printTest() {
System.out.println("Running JUNIT test");
}
}
The response is that there are no test cases to run.
Thanks for your insight
maven junit maven-surefire-plugin junit5
Im trying to get a simple junit test running with maven but it is not detecting any tests. Where am I going wrong? The project directory
Project -> src -> test-> java -> MyTest.java
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
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.buildproftest.ecs</groupId>
<artifactId>buildprofiletest</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.3.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<debug>false</debug>
<optimize>true</optimize>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Junit test case
import org.junit.jupiter.api.Test;
public class MyTest {
@Test
public void printTest() {
System.out.println("Running JUNIT test");
}
}
The response is that there are no test cases to run.
Thanks for your insight
maven junit maven-surefire-plugin junit5
maven junit maven-surefire-plugin junit5
edited Feb 6 at 6:09
LaurentG
8,06073755
8,06073755
asked Nov 22 '18 at 15:01
mogolimogoli
4031522
4031522
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
According to the annotation (import org.junit.jupiter.api.Test
), you are trying to run JUnit 5 tests with Maven. According to the documentation, you have to add this dependency:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.3.1</version>
<scope>test</scope>
</dependency>
Your version of Maven comes with a version of maven-surefire-plugin
which does not support JUnit 5. You could update your Maven to the latest version. You could also set the version of the maven-surefire-plugin
:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<!-- JUnit 5 requires Surefire version 2.22.0 or higher -->
<version>2.22.0</version>
</plugin>
See the junit5-samples for this information.
See the Maven Surefire Plugin artifact in a Maven repository. At version 3.0.0-M3
as of 2019-01.
1
I added the dependency and ran mvn clean test but no test run still. Thanks.
– mogoli
Nov 22 '18 at 15:07
Why have you also the JUnit 4.12 as dependency? It might be the problem. Try to remove it.
– LaurentG
Nov 22 '18 at 15:11
I've removed that now and still no joy. I ran the test through my IDE independent of maven and it does run. Thanks
– mogoli
Nov 22 '18 at 15:13
I could reproduce the problem and fix it with the version ofmaven-surefire-plugin
.
– LaurentG
Nov 22 '18 at 15:27
1
Tip: As of JUnit 5 version 5.4.0, you can use the new convenient single Maven artifact named JUnit Jupiter (Aggregator) that in turn gets you several related artifacts needed to write and run JUnit 5 tests:junit-jupiter
– Basil Bourque
Jan 29 at 2:23
|
show 4 more comments
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53433663%2fmaven-not-running-junit-5-tests%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
According to the annotation (import org.junit.jupiter.api.Test
), you are trying to run JUnit 5 tests with Maven. According to the documentation, you have to add this dependency:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.3.1</version>
<scope>test</scope>
</dependency>
Your version of Maven comes with a version of maven-surefire-plugin
which does not support JUnit 5. You could update your Maven to the latest version. You could also set the version of the maven-surefire-plugin
:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<!-- JUnit 5 requires Surefire version 2.22.0 or higher -->
<version>2.22.0</version>
</plugin>
See the junit5-samples for this information.
See the Maven Surefire Plugin artifact in a Maven repository. At version 3.0.0-M3
as of 2019-01.
1
I added the dependency and ran mvn clean test but no test run still. Thanks.
– mogoli
Nov 22 '18 at 15:07
Why have you also the JUnit 4.12 as dependency? It might be the problem. Try to remove it.
– LaurentG
Nov 22 '18 at 15:11
I've removed that now and still no joy. I ran the test through my IDE independent of maven and it does run. Thanks
– mogoli
Nov 22 '18 at 15:13
I could reproduce the problem and fix it with the version ofmaven-surefire-plugin
.
– LaurentG
Nov 22 '18 at 15:27
1
Tip: As of JUnit 5 version 5.4.0, you can use the new convenient single Maven artifact named JUnit Jupiter (Aggregator) that in turn gets you several related artifacts needed to write and run JUnit 5 tests:junit-jupiter
– Basil Bourque
Jan 29 at 2:23
|
show 4 more comments
According to the annotation (import org.junit.jupiter.api.Test
), you are trying to run JUnit 5 tests with Maven. According to the documentation, you have to add this dependency:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.3.1</version>
<scope>test</scope>
</dependency>
Your version of Maven comes with a version of maven-surefire-plugin
which does not support JUnit 5. You could update your Maven to the latest version. You could also set the version of the maven-surefire-plugin
:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<!-- JUnit 5 requires Surefire version 2.22.0 or higher -->
<version>2.22.0</version>
</plugin>
See the junit5-samples for this information.
See the Maven Surefire Plugin artifact in a Maven repository. At version 3.0.0-M3
as of 2019-01.
1
I added the dependency and ran mvn clean test but no test run still. Thanks.
– mogoli
Nov 22 '18 at 15:07
Why have you also the JUnit 4.12 as dependency? It might be the problem. Try to remove it.
– LaurentG
Nov 22 '18 at 15:11
I've removed that now and still no joy. I ran the test through my IDE independent of maven and it does run. Thanks
– mogoli
Nov 22 '18 at 15:13
I could reproduce the problem and fix it with the version ofmaven-surefire-plugin
.
– LaurentG
Nov 22 '18 at 15:27
1
Tip: As of JUnit 5 version 5.4.0, you can use the new convenient single Maven artifact named JUnit Jupiter (Aggregator) that in turn gets you several related artifacts needed to write and run JUnit 5 tests:junit-jupiter
– Basil Bourque
Jan 29 at 2:23
|
show 4 more comments
According to the annotation (import org.junit.jupiter.api.Test
), you are trying to run JUnit 5 tests with Maven. According to the documentation, you have to add this dependency:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.3.1</version>
<scope>test</scope>
</dependency>
Your version of Maven comes with a version of maven-surefire-plugin
which does not support JUnit 5. You could update your Maven to the latest version. You could also set the version of the maven-surefire-plugin
:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<!-- JUnit 5 requires Surefire version 2.22.0 or higher -->
<version>2.22.0</version>
</plugin>
See the junit5-samples for this information.
See the Maven Surefire Plugin artifact in a Maven repository. At version 3.0.0-M3
as of 2019-01.
According to the annotation (import org.junit.jupiter.api.Test
), you are trying to run JUnit 5 tests with Maven. According to the documentation, you have to add this dependency:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.3.1</version>
<scope>test</scope>
</dependency>
Your version of Maven comes with a version of maven-surefire-plugin
which does not support JUnit 5. You could update your Maven to the latest version. You could also set the version of the maven-surefire-plugin
:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<!-- JUnit 5 requires Surefire version 2.22.0 or higher -->
<version>2.22.0</version>
</plugin>
See the junit5-samples for this information.
See the Maven Surefire Plugin artifact in a Maven repository. At version 3.0.0-M3
as of 2019-01.
edited Jan 29 at 2:14
Basil Bourque
115k29394557
115k29394557
answered Nov 22 '18 at 15:04
LaurentGLaurentG
8,06073755
8,06073755
1
I added the dependency and ran mvn clean test but no test run still. Thanks.
– mogoli
Nov 22 '18 at 15:07
Why have you also the JUnit 4.12 as dependency? It might be the problem. Try to remove it.
– LaurentG
Nov 22 '18 at 15:11
I've removed that now and still no joy. I ran the test through my IDE independent of maven and it does run. Thanks
– mogoli
Nov 22 '18 at 15:13
I could reproduce the problem and fix it with the version ofmaven-surefire-plugin
.
– LaurentG
Nov 22 '18 at 15:27
1
Tip: As of JUnit 5 version 5.4.0, you can use the new convenient single Maven artifact named JUnit Jupiter (Aggregator) that in turn gets you several related artifacts needed to write and run JUnit 5 tests:junit-jupiter
– Basil Bourque
Jan 29 at 2:23
|
show 4 more comments
1
I added the dependency and ran mvn clean test but no test run still. Thanks.
– mogoli
Nov 22 '18 at 15:07
Why have you also the JUnit 4.12 as dependency? It might be the problem. Try to remove it.
– LaurentG
Nov 22 '18 at 15:11
I've removed that now and still no joy. I ran the test through my IDE independent of maven and it does run. Thanks
– mogoli
Nov 22 '18 at 15:13
I could reproduce the problem and fix it with the version ofmaven-surefire-plugin
.
– LaurentG
Nov 22 '18 at 15:27
1
Tip: As of JUnit 5 version 5.4.0, you can use the new convenient single Maven artifact named JUnit Jupiter (Aggregator) that in turn gets you several related artifacts needed to write and run JUnit 5 tests:junit-jupiter
– Basil Bourque
Jan 29 at 2:23
1
1
I added the dependency and ran mvn clean test but no test run still. Thanks.
– mogoli
Nov 22 '18 at 15:07
I added the dependency and ran mvn clean test but no test run still. Thanks.
– mogoli
Nov 22 '18 at 15:07
Why have you also the JUnit 4.12 as dependency? It might be the problem. Try to remove it.
– LaurentG
Nov 22 '18 at 15:11
Why have you also the JUnit 4.12 as dependency? It might be the problem. Try to remove it.
– LaurentG
Nov 22 '18 at 15:11
I've removed that now and still no joy. I ran the test through my IDE independent of maven and it does run. Thanks
– mogoli
Nov 22 '18 at 15:13
I've removed that now and still no joy. I ran the test through my IDE independent of maven and it does run. Thanks
– mogoli
Nov 22 '18 at 15:13
I could reproduce the problem and fix it with the version of
maven-surefire-plugin
.– LaurentG
Nov 22 '18 at 15:27
I could reproduce the problem and fix it with the version of
maven-surefire-plugin
.– LaurentG
Nov 22 '18 at 15:27
1
1
Tip: As of JUnit 5 version 5.4.0, you can use the new convenient single Maven artifact named JUnit Jupiter (Aggregator) that in turn gets you several related artifacts needed to write and run JUnit 5 tests:
junit-jupiter
– Basil Bourque
Jan 29 at 2:23
Tip: As of JUnit 5 version 5.4.0, you can use the new convenient single Maven artifact named JUnit Jupiter (Aggregator) that in turn gets you several related artifacts needed to write and run JUnit 5 tests:
junit-jupiter
– Basil Bourque
Jan 29 at 2:23
|
show 4 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53433663%2fmaven-not-running-junit-5-tests%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown