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.

Maven Surefire Plugin is used during the test phase of the build lifecycle to execute the unit tests of an application.

It runs unit tests of a maven project and produces reports in text, XML and HTML format. By default, it will fail the build if the unit tests fail. It supports multiple unit test frameworks, notably JUnit and TestNG.

Its only goal is the test goal. Check its official usage page for a first sample.

1351 questions
63
votes
6 answers

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 find or load main class …
jediz
  • 4,459
  • 5
  • 36
  • 41
60
votes
3 answers

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 surefire configuration ...
Dave A
  • 2,780
  • 9
  • 41
  • 60
55
votes
9 answers

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 doing : mvn -Dtest= integration-test but…
Jalpesh
  • 1,603
  • 2
  • 13
  • 15
48
votes
4 answers

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/integration tests in their respective phases. This…
Christopher Klewes
  • 11,181
  • 18
  • 74
  • 102
47
votes
6 answers

Maven -DskipTests ignored

I'm building a Maven project with following SureFire configuration: org.apache.maven.plugins maven-surefire-plugin ${version.maven-surefire-plugin}
NeplatnyUdaj
  • 6,052
  • 6
  • 43
  • 76
47
votes
12 answers

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 ?
ravinikam
  • 3,666
  • 6
  • 28
  • 25
46
votes
1 answer

how to pass --add-opens JDK module configuration to maven test

I'm upgrading java version in our production code from java 8 to java 11. I have to add the below JDK module configuration in the application java start command due to usage of third party libraries like flume, zookeeper etc. --add-opens…
45
votes
3 answers

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?
user1137387
  • 1,933
  • 3
  • 18
  • 27
44
votes
10 answers

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 Unit Tests and Integration Tests) as well.…
43
votes
8 answers

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(equalTo("Patisnummer"), "Field key", "Field key")…
Kasper van den Berg
  • 8,951
  • 4
  • 48
  • 70
42
votes
1 answer

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 -DskipTests=true => no tests are executed mvn clean…
41
votes
5 answers

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-classes. But it doesn't copy resources from…
tpdi
  • 34,554
  • 11
  • 80
  • 120
41
votes
12 answers

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 several forks. My problem is that running this setup…
Nitzan Volman
  • 1,809
  • 3
  • 17
  • 31
35
votes
3 answers

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 and run using Surefire plugin. We don't have…
31
votes
5 answers

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: ../foo-core
Kirin Yao
  • 1,606
  • 2
  • 14
  • 21
1
2
3
90 91