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

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 because, i used tests (helper) classes in another…
Antoine
  • 4,456
  • 4
  • 44
  • 51
26
votes
4 answers

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) Tests run: 3, Failures: 1, Errors: 0, Skipped:…
pavel_kazlou
  • 1,995
  • 4
  • 28
  • 34
26
votes
3 answers

Problem running tests with enabled preview features in surefire and failsafe

I'm trying to migrate a project to Java 12, with --enable-preview. I added --enable-preview in compiler settings: maven-compiler-plugin
26
votes
2 answers

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.
user1714259
23
votes
3 answers

Append the value of argLine param in maven-surefire-plugin

I am using maven-surefire-plugin + Sonar together and I would like to add some extra value to argLine parameter of the maven-surefire-plugin. So I did it:
zappee
  • 20,148
  • 14
  • 73
  • 129
22
votes
2 answers

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 being special cases, can you use profiles to…
Lucas
  • 14,227
  • 9
  • 74
  • 124
20
votes
4 answers

Set surefire plugin Locale in Maven pom file

I read in maven-surefire-plugin and default locale that Maven runs tests forked and thus might lose any locale you might have set. Is there a way to run tests in Maven in forked mode and still retain locale? -- EDIT -- So, to clarify a bit: It is…
JHollanti
  • 2,343
  • 8
  • 27
  • 39
19
votes
3 answers

Maven does not run @BeforeEach Methods while running

i have a test Class lets call it TestSomething, and a Test Object lets call this one SomeObject. Now i need this Object in every Single Test new this means that i have in my Code a @BeforeEach that loads this Object in a Field: import…
Luca
  • 300
  • 1
  • 4
  • 11
19
votes
1 answer

Maven - Get list of all tests without running them?

I have a maven project and I would like to get a list of all the test classes and their file paths, without having to execute all the tests. After I run "mvn test", the only files that I have under target/ are checkstyle-cachefile …
greenberet123
  • 1,351
  • 1
  • 12
  • 22
19
votes
7 answers

Maven build and maven-failsafe-plugin - The forked VM terminated without properly saying goodbye

I use Docker and https://github.com/fabric8io/docker-maven-plugin for my integration tests. On my Windows 10 (after updating to Windows 10 1709) machine I faced the following error with my Maven 3.5.0 build: [ERROR] Failed to execute goal…
alexanoid
  • 24,051
  • 54
  • 210
  • 410
19
votes
1 answer

How to exclude all JUnit4 tests with a given category using Maven surefire?

I intend on annotating some of my JUnit4 tests with an @Category annotation. I would then like to exclude that category of tests from running on my Maven builds. I see from the Maven documentation that it is possible to specify a category of tests…
Adam
  • 43,763
  • 16
  • 104
  • 144
18
votes
3 answers

How to override log4j.properties during testing?

I'm trying to log all DEBUG messages to console during testing in maven. For this purpose I created a file src/test/resources/log4j.properties, which is going to override the configuration I already have in src/main/resources/log4j.properties.…
yegor256
  • 102,010
  • 123
  • 446
  • 597
18
votes
4 answers

How can I stop maven from running TEST twice?

I have a big project with around 5000 test cases. When running mvn clean install it will run the test goal twice (one as part of the install and the second time as part of the surefire plugin). Why it needs to run the test for the second time? And…
DhafirNz
  • 627
  • 3
  • 9
  • 20
17
votes
3 answers

Using the Maven surefire plugin to include tests

I am using Maven to build my project. I currently split testing into different hierarchies: Unit tests -> src/test/java/**/*Test.java Integration tests -> src/test-integration/java/**/*Test.java External tests ->…
kevinarpe
  • 20,319
  • 26
  • 127
  • 154
17
votes
2 answers

What does the "default-test" stand for in the maven-surefire plugin

I have defined the following configuration in my pom for surefire with TestNg: org.apache.maven.plugins maven-surefire-plugin 2.12
Peter De Winter
  • 1,183
  • 2
  • 15
  • 27
1 2
3
90 91