Questions tagged [maven-surefire-plugin]
The Surefire Plugin is used during the test phase of the build lifecycle to execute the unit tests of an application. It is commonly used in continuous integration.
1,513
questions
283votes
5answers
169kviews
Making Maven run all tests, even when some fail
I have a project with several modules. When all tests pass, Maven test runs them all.
When tests fail in the first module, maven will not continue to the next project. I have testFailureIgnore set to ...
281votes
61answers
274kviews
The forked VM terminated without saying properly goodbye. VM crash or System.exit called
Please help me to solve this issue. I do not exactly understand what the error in the log means.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[...
225votes
20answers
83kviews
Maven surefire could not find ForkedBooter class
Recently coming to a new project, I'm trying to compile our source code. Everything worked fine yesterday, but today is another story.
Every time I'm running mvn clean install on a module, once ...
187votes
10answers
258kviews
How do I get my Maven Integration tests to run
I have a maven2 multi-module project and in each of my child modules I have JUnit tests that are named Test.java and Integration.java for unit tests and integration tests respectively. When I execute:...
183votes
6answers
62kviews
How can I get maven-release-plugin to skip my tests?
How can I get the maven-release-plugin to run without triggering the tests?
I have tried
-Dmaven.test.skip=true
and
-DskipTests
and
-DpreparationGoals=clean
...yet none work.
Yes, I know ...
179votes
7answers
68kviews
Prevent unit tests but allow integration tests in Maven
I've a Maven build in which I use the SureFire plugin to run some unit tests, and the FailSafe plugin to run some integration tests. I would like a way to run just the FailSafe plugin's tests.
It's ...
144votes
18answers
74kviews
Surefire is not picking up Junit 5 tests
I wrote a simple test method with JUnit 5:
public class SimlpeTest {
@Test
@DisplayName("Some description")
void methodName() {
// Testing logic for subject under test
}
}
...
138votes
3answers
46kviews
What is the difference between the Maven Surefire and Maven Failsafe plugins?
What is the difference between Maven Surefire and Maven Failsafe plugins?
I have searched all over web, but did not get the answer.
116votes
18answers
123kviews
JUnit tests pass in Eclipse but fail in Maven Surefire
I have written some JUnit tests using JUnit 4 and spring-test libraries. When I run the tests inside Eclipse then run fine and pass. But when I run them using Maven (during the build process), they ...
114votes
3answers
39kviews
Make maven's surefire show stacktrace in console
I'd like to see the stacktrace of unit tests in the console. Does surefire support this?
84votes
5answers
56kviews
IntelliJ Error when running unit test: Could not find or load main class ${surefireArgLine}
I get the following error when running Unit tests in IntelliJ:
Error: Could not find or load main class ${surefireArgLine}.
I am using maven and in pom.xml I have:
<properties>
...
<...
77votes
9answers
62kviews
How to run JUnit tests by category in Maven?
Using JUnit 4.8 and the new @Category annotations, is there a way to choose a subset of categories to run with Maven's Surefire plugin?
For example I have:
@Test
public void a() {
}
@Category(...
76votes
6answers
55kviews
Is there a way to skip only a single test in maven?
I would like to skip only a single test while launching mvn install.
Is there a way to do that ?
71votes
10answers
56kviews
Cannot use jacoco JVM args and surefire JVM args together in maven
I am using maven with the jacoco plugin to generate code coverage metrics. I am having some difficulty in configuring the surefire plugin with the java options required by the jacoco plugin. I've seen ...
71votes
12answers
46kviews
Surefire Maven plugin: "Corrupted STDOUT by directly writing to native stream in forked JVM"
My JUnit tests are failing when running them through Maven and the Surefire plugin (version information below). I see the error message:
Corrupted STDOUT by directly writing to native stream in forked ...
71votes
6answers
96kviews
How to get a test resource file?
In a unit test I need to import a csv file. This is located in the resources folder, i.e. src/test/resources
66votes
7answers
90kviews
How can I skip tests in maven install goal, while running them in maven test goal?
I have a multi-module maven project with both integration and unit tests in the same folder (src/test/java). Integration tests are marked with @Category(IntegrationTest.class). I want to end up with ...
63votes
6answers
33kviews
Spring Boot fails to run maven-surefire-plugin ClassNotFoundException org.apache.maven.surefire.booter.ForkedBooter
Running maven (3.5.2) build of a Spring Boot 2.0.2.RELEASE applicaton (generated by web initialiser with web dependencies) fails executing the maven-surefire-plugin saying just:
Error: Could not ...
61votes
5answers
66kviews
What is the use of Maven-Surefire plugin
What is the use of the Maven Surefire Plugin?
I can not find a proper example.
56votes
3answers
40kviews
How do I make Jenkins build fail when Maven unit tests fail?
I'm using Jenkins, Maven 3.1, and Java 1.6. I have the following Maven job set up in Jenkins with the following goals and options ...
clean install -U -P cloudbees -P qa
below is my pom.xml ...
54votes
7answers
23kviews
Is there a way to "fail fast" for junit with the maven surefire plugin?
I'm currently working on a java project using maven. We use the maven surefire plugin to run our junit suite as part of the build process.
Our test suite is rapidly growing, in both coverage and ...
52votes
1answer
12kviews
TypeNotPresentExceptionProxy
When upgrading from Surefire 2.6 to Surefire 2.13, I get a TypeNotPresentExceptionProxy when running my unit tests.
java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
...
49votes
9answers
37kviews
How to run individual test in the integration-test target in maven
We have a hundreds of tests defined for our integration-test phase lifecycle in maven, and they take a long time to finish.
What I want to do is run just one test in the integration-test. I tried ...
46votes
8answers
52kviews
Is there a decent HTML Junit report plugin for Maven?
I find the surefire-report plug-in very unsuitable to my working style. I clean the project all the time and I don't want to spend 5 min to rebuild the whole site every time I want to look at the test ...
45votes
12answers
33kviews
How to execute JUnit and TestNG tests in same project using maven-surefire-plugin?
Right now I have both type of tests but when I say "mvn test" it only executes TestNG tests and not Junit. I want to execute both one after another. Any Idea ?
44votes
4answers
56kviews
Howto add another test source folder to Maven and compile it to a separate folder?
I have the default src/test/java folder for our unit tests. A separate folder src/integration/java is available for the integration tests.
I configured the maven-surefire-plugin to execute the unit/...
43votes
6answers
120kviews
Maven -DskipTests ignored
I'm building a Maven project with following SureFire configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</...
43votes
8answers
29kviews
NoSuchMethodError with Hamcrest 1.3 & JUnit 4.11
Another instance of the NoSuchMethodError for the JUnit & Hamcrest combination.
Offending code:
assertThat(dirReader.document(0).getFields(), hasItem(
new FeatureMatcher<IndexableField, ...
40votes
13answers
67kviews
Surefire is not picking up Junit 4 tests
For some reason I cannot get Maven 2 Surefire plugin to execute JUnit 4 test class.
public class SimpleTest {
@org.junit.Test
public void simple() {
System.out.println("foo");
}
}
However ...
40votes
3answers
28kviews
Maven not running JUnit 5 tests
I'm 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
...
40votes
8answers
23kviews
Merging Integration and Unit test reports with JaCoCo
I am generating failsafe and surefire reports with maven with the JaCoCo plugin, but I can only manage to get them in separate reports. I would like to have a overall coverage view (merge between both ...
40votes
5answers
58kviews
Maven (Surefire): copy test resources from src/test/java
Maven's Surefire (testing) pluginmvn test-compile copies files in src/test/resources to target/test-classes. It compiles .java in src/test/java, and copies the compiled .class files to target/test-...
40votes
12answers
51kviews
Strategy for debugging surefire "The forked VM terminated without saying properly goodbye. VM crash or System.exit called ?"
I am working on a rather complex java project with many dependencies and many unit tests.
I am using java 1.6.0_65 on mac (mavericks) with maven 3.0.5 with maven-surefire-plugin:2.16 running in ...
40votes
2answers
41kviews
Maven Surefire plugin "Error occured in starting fork, check output in log"
I get the following error
BUILD ERROR
Error occured in starting fork, check output in log
when using Maven 2.2.1 and Surefire plugin 2.11 while running junit test cases.
How can I fix it?
38votes
3answers
33kviews
Maven 2.1.0 not passing on system properties to Java virtual machine
We use the command line to pass on system properties to the Java
virtual machine when running our Hudson builds on a Linux box. It used
to work quite well in 2.0.9 by since we upgraded to 2.1.0 it ...
37votes
1answer
18kviews
Maven separate Unit Test and Integration Tests
UT = Unit Tests
IT = Integration Tests. All my Integration test classes are annotated with @Category(IntegrationTest.class)
My goal is:
mvn clean install => runs UT and not IT
mvn clean install -...
34votes
3answers
24kviews
Is there a way to tell surefire to skip tests in a certain package?
Something like the following.
I would like a way to skip my dao tests in surefire. Trying to avoid overhead of defining Suites.
With CI I'd like to have one nightly that runs all tests and another ...
34votes
3answers
12kviews
Benefits of Maven FailSafe Plugin
I read Maven Failsafe plugin is designed specifically to run integration tests. Currently I'm working on a multi-module project and integration tests are in its own separate module, written in TestNg ...
32votes
1answer
31kviews
Setting timezone for maven unit tests on Java 8
How do I set the timezone for unit tests in maven surefire on Java 8?
With Java 7 this used to work with systemPropertyVariables like in the following configuration, but with Java 8 the tests just ...
30votes
6answers
94kviews
How to pass java code a parameter from maven for testing
I need to pass on following values …
exeEvironment (Test environment) ,
testGroup (Group in testNG)
from Command-Line -> POM -> TestNG -> Test cases.
Based on these two posts ....
pass a java ...
29votes
4answers
31kviews
Maven doesn't execute any unit test
I am using Maven with multi-modules. There are 3 projects.
foo(the parent project)
foo-core
foo-bar
I configure all the dependencies and plugins in foo's pom:
<modules>
<module>../...
28votes
4answers
40kviews
Logging level under maven surefire
I'm unable to adjust java logging's logging level. I'm using maven surefire (mvn test), and trying to adjust from the default INFO to e.g. FINEST.
I have logging.properties file under src/test/...
27votes
3answers
18kviews
Run JUnit Tests contained in dependency jar using Maven Surefire
I have a jar in my maven repository that contains junit tests, which should be run in different projects, because it is able to inspect the project and test for certain features of it. Unforunately ...
27votes
2answers
34kviews
Maven surefire plugin fork mode
By default maven surefile plugin run tests in isolated (forked) environment. You can override this behavior with following configuration:
<build>
<plugins>
<plugin>
<...
26votes
4answers
26kviews
how to debug maven surefire test more easily (using eclipse as debug server)
I'm using maven / surefire / eclipse to write some code and later test / debug it.
Standard way to do it is by using maven.surefire.debug maven property. By default, when this property is enabled, ...
25votes
3answers
31kviews
Output failed test details to stdout using maven surefire
When I run my build using maven 2
mvn clean install
my tests are run by surefire plug-in. In case test failed I get the following output:
Results :
Failed tests:
test1(com.my.MyClassTest)
...
24votes
2answers
23kviews
Generate test-jar along with jar file in test package
I want to package my test package to jar file . How to execute generate test-jar from maven plugin Surefire.
24votes
2answers
13kviews
Surefire doesn't launch test in src/main/java
I needed to move some src/test/java to src/main/java according to this recommandation from maven-jar-plugin documentation => http://maven.apache.org/plugins/maven-jar-plugin/usage.html
I did so ...
21votes
1answer
37kviews
Generating html surefire test html output during test phase
I'm not sure if this is a simple question or not, but I'd like surefire to generate html formatted output files(in addition to the xml and txt formatted output files) during the test phase.
I've ...
21votes
2answers
12kviews
maven-surefire-plugin include/exclude precedence
When using the maven-surefire-plugin and both includes and excludes, which order are they processed in? Furthermore, if you have 3 sets of tests, the first being the base set, the second and third ...