maven-surefire-plugin

Cannot use jacoco JVM args and surefire JVM args together in maven

为君一笑 提交于 2019-11-27 11:45:36
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 Overflow but something is not working for me. I have a multi-module project, and one of my modules configures the surefire plugin as follows: foo/pom.xml : <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <argLine>-XX:MaxPermSize=512m</argLine> </configuration> </plugin> </plugins

How to execute JUnit and TestNG tests in same project using maven-surefire-plugin?

我的梦境 提交于 2019-11-27 10:29:03
问题 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 ? 回答1: There is an open issue for this, so there's no elegant way to do this. It would be far simpler for you to pick a framework and stick with it. Edit: My previous answer doesn't work because you can't specify dependencies in the execution. I've tried a few approaches, but the best I can manage is to create a profile for the TestNG

How can I skip tests in maven install goal, while running them in maven test goal?

…衆ロ難τιáo~ 提交于 2019-11-27 06:06:42
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 all tests to compile, but I do not want to execute any. If I run mvn test , I want all tests to compile, but execute only unit tests. If I run mvn integration-test , I want to compile and execute all tests. The important point is, I want this configured in the pom.xml without any extra commandline arguments. Currently I came up with the following

Prevent unit tests but allow integration tests in Maven

試著忘記壹切 提交于 2019-11-27 05:51:42
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 profiles or anything in the pom, because it's a multimodule build and I don't want to have to edit every module's pom. There are skip.tests and maven.test.skip and skipTests which stop all tests, and skipITs , which stops only the failsafe plugin. So, is there a command-line flag for Maven like skipITs , but instead with the functionality of "onlyITs"? I

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

三世轮回 提交于 2019-11-27 05:40:55
问题 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 to run. I want to know how to specify a category of tests not to run. Thanks! 回答1: You can do this as follows: Your pom.xml should contain the following setup. <configuration> <excludes> <exclude>**/TestCircle.java</exclude> <exclude>**/TestSquare

Strategy for debugging surefire “The forked VM terminated without saying properly goodbye. VM crash or System.exit called ?”

给你一囗甜甜゛ 提交于 2019-11-27 04:20:16
问题 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 with several forks causes a fork to exit with: "The forked VM terminated without saying properly goodbye. VM crash or System.exit called ?" running this with only one fork does not produce the problem (and everything passes) There is some information

How to run JUnit tests by category in Maven?

旧街凉风 提交于 2019-11-27 03:00:25
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 to run all non-slow tests as in: (note that the -Dtest.categories was made up by me...). mvn test -Dtest.categories=!SlowTests // run non-slow tests mvn test -Dtest.categories=SlowTests // run only slow tests mvn test -Dtest.categories=SlowTests,FastTests // run only slow tests and fast tests mvn test // run all tests, including non-categorized So

How do I make Jenkins build fail when Maven unit tests fail?

筅森魡賤 提交于 2019-11-27 01:27:01
问题 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 ... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.17</version> <configuration> <reuseForks>true</reuseForks> <argLine>-Xmx2048m -XX:MaxPermSize=512M </argLine> <skipTests>false</skipTests> </configuration> </plugin>

Spring Boot fails to run maven-surefire-plugin ClassNotFoundException org.apache.maven.surefire.booter.ForkedBooter

半腔热情 提交于 2019-11-27 00:33:31
问题 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 org.apache.maven.surefire.booter.ForkedBooter Caused by: java.lang. ClassNotFoundException : org.apache.maven.surefire.booter. ForkedBooter Why is this happening? Is it a problem in boot + surefire integration = a bug? For reference, the dependencies that seem relevant are:

Maven surefire could not find ForkedBooter class

拈花ヽ惹草 提交于 2019-11-26 23:36:07
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] --- maven-surefire-plugin:2.18.1:test (default-test) @ recorder --- [INFO] Surefire report directory: /lhome/code/recorder/target/surefire-reports [INFO] Using configured provider org.apache.maven.surefire.junitcore.JUnitCoreProvider [INFO] parallel='none', perCoreThreadCount=true, threadCount=0, useUnlimitedThreads=false, threadCountSuites=0,