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
12
votes
2 answers

Pass JVM args to maven surefire, conditional on build Java version?

Is there a way that I can pass this argLine configuration to the maven-surefire plugin ONLY when 1.7 is configured for Java 1.7 but NOT when a user changes the pom.xml to be configured for java 1.8? The reason being that…
djangofan
  • 28,471
  • 61
  • 196
  • 289
12
votes
2 answers

Setting properties via Maven command line

I'm confused about the correct way to set a property for some unit tests via the command line when using Maven. There are a number of questions (e.g. Specifying Maven memory parameter without setting MAVEN_OPTS environment variable, Is there a way…
ksl
  • 4,519
  • 11
  • 65
  • 106
12
votes
3 answers

maven surefire: how to print current test being run?

Is there any way to get maven surefire to print the name of every unit test (i.e., test method) it's starting? Something like: testFoo: ... passed testBar: ... failed
Gal
  • 5,338
  • 5
  • 33
  • 55
12
votes
3 answers

How to configure maven surefire to use an jvm agent that is a dependency?

I would like to configure the maven sure fire plugin to start the unit testing jvm with the argument for a java agent. The agent jar file is being obtained from maven central so I want maven to automatically figure out the path to the agent's jar…
ams
  • 60,316
  • 68
  • 200
  • 288
11
votes
2 answers

Maven surefire and JDK 11

I'm trying to get Maven surefire to run under JDK 11 but I keep getting these errors: If I set reuseForks to true: Error occurred in starting fork, check output in log Process Exit Code: 1 at…
Gnas
  • 698
  • 1
  • 6
  • 14
11
votes
6 answers

Maven error occurred in starting fork, check output in log

I use Maven, docker-maven-plugin and Spring Boot. Right now I run into the following issue: [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 03:08 min [INFO] Finished at:…
alexanoid
  • 24,051
  • 54
  • 210
  • 410
11
votes
1 answer

Removing logback `INFO` messages from Maven Console for junit tests

I have placed a logback.xml in src/test/resources from my maven project. My intention is to have a separate logback config for my tests and actual code. My logback.xml looks like below:-
tuk
  • 5,941
  • 14
  • 79
  • 162
10
votes
3 answers

Maven + Surefire: proxy configuration

I'm using httpunit to access a server. I need to configure the proxy settings for this (http and https). I set the configuration in the settings.xml file, but surefire seems to ignore it!? I want to avoid to duplicate the configuration as much as…
Puce
  • 37,247
  • 13
  • 80
  • 152
10
votes
1 answer

Error when executing tests in java maven jacoco: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test

Error when executing tests in java maven jacoco: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test Good Morning. I am carrying out a Maven project and I use NetBeans to write Java code. When I try to run a test file,…
Rui Ribeiro
  • 101
  • 1
  • 1
  • 4
10
votes
3 answers

How to change maven's Remote Repository URL in the NetBeans IDE (from http to https)?

When trying to run a NetBeans project, I get the following error message: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test (default-test) on project MyNetBeansProject: Execution default-test of goal …
steady_progress
  • 3,311
  • 10
  • 31
  • 62
10
votes
1 answer

Maven Surefire with JUnit 5 hiding stacktraces

If I do this: mvn -X \ -Dtest=MojoIntegrationTest \ -Dsurefire.trimStackTrace=false \ -Dsurefire.useFile=false \ clean test @BeforeEach public void setUp() { stuff(); } @Test public void testMyApp() { doApp(); } and…
Adam
  • 5,215
  • 5
  • 51
  • 90
10
votes
2 answers

How to change default maven surefire plugin to higher version?

Now I'm running Maven 3.0.3 and it uses maven-surefire-plugin:2.7.2, but I want Maven to use a higher version of maven-surefire-plugin…
Timofey Gorshkov
  • 4,987
  • 6
  • 41
  • 66
10
votes
1 answer

Maven won't run tests

When running mvn test maven won't run all Test Classes. When I explicitly provide a class by adding -Dtest=PropertyTests the tests will be run. Here's my pom.xml: **/*Spec.*
dtrunk
  • 4,685
  • 17
  • 65
  • 109
9
votes
6 answers

How to run a maven goal when there is tests failures?

I would like to know if there is a way to execute a goal when there is test failures? Since maven stops its execution (fail fast mode) after encountering a test failure, is there any options to launch a goal when there is test failures? Regards.
xavier.seignard
  • 11,254
  • 13
  • 51
  • 75
9
votes
2 answers

Maven: Surefire --dry-run?

Is there some way to dry-run surefire? Something which would list which tests would run, without running them. The goal is, to know which tests (would) run in JBoss AS7 testsuite under certain config.
Ondra Žižka
  • 43,948
  • 41
  • 217
  • 277