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
315
votes
68 answers

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 [INFO]…
astack
  • 3,837
  • 7
  • 22
  • 21
313
votes
5 answers

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 true in Surefire settings, but it doesn't…
ripper234
  • 222,824
  • 274
  • 634
  • 905
227
votes
20 answers

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 reaching the tests, it crashes into an error: [INFO]…
Sylordis
  • 2,528
  • 3
  • 17
  • 20
192
votes
7 answers

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 not a good solution for me to add different…
183
votes
6 answers

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 I shouldn't release if the tests don't pass, but I…
Steven
  • 2,189
  • 3
  • 15
  • 12
156
votes
19 answers

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 } } But when I run mvn test, I…
Ali Dehghani
  • 46,221
  • 15
  • 164
  • 151
142
votes
3 answers

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.
bugCracker
  • 3,656
  • 9
  • 37
  • 58
130
votes
3 answers

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?
IAdapter
  • 62,595
  • 73
  • 179
  • 242
90
votes
13 answers

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 JVM 4. See FAQ web page and the dump file…
user118967
  • 4,895
  • 5
  • 33
  • 54
89
votes
6 answers

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: ...
BlueLettuce16
  • 2,013
  • 4
  • 20
  • 31
87
votes
9 answers

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 Results : Tests run: 0, Failures: 0, Errors: 0, Skipped:…
mogoli
  • 2,153
  • 6
  • 26
  • 41
79
votes
9 answers

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(SlowTests.class) @Test public void b() { } And I'd like…
Ran
  • 7,541
  • 12
  • 59
  • 72
78
votes
10 answers

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 some answers about this already on Stack…
John Q Citizen
  • 3,138
  • 4
  • 26
  • 31
70
votes
7 answers

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 the following setup: If I run mvn install, I want…
69
votes
5 answers

What is the use of Maven-Surefire plugin

What is the use of the Maven Surefire Plugin? I can not find a proper example.
prasannajit
  • 799
  • 2
  • 6
  • 7
1
2 3
90 91