maven-surefire-plugin

Running code before and after all tests in a surefire execution

喜欢而已 提交于 2019-12-05 09:10:54
I have a Grizzly HttpServer that I want to run for the entire duration of a test group execution. Additionally, I want to interact with the global HttpServer instance from a @Rule inside the tests themselves. Since I'm using Maven Surefire rather than using JUnit test suites, I can't use @BeforeClass / @AfterClass on the test suite itself. Right now, all I can think of is lazily initialising a static field and stopping the server from a Runtime.addShutdownHook() -- not nice! Matthew Farwell There are two options, a maven solution and a surefire solution. The least coupled solution is to

Java 8: What is the equivalent of “UseSplitVerifier”?

…衆ロ難τιáo~ 提交于 2019-12-05 05:17:15
I'm using Maven 3.2.3 on Mac 10.9.5 and have this for my compiler plugin ... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.8</source> <target>1.8</target> <compilerArgument>-proc:none</compilerArgument> <fork>true</fork> <!-- <compilerId>eclipse</compilerId>--> </configuration> <executions> <execution> <id>default-testCompile</id> <phase>test-compile</phase> <goals> <goal>testCompile</goal> </goals> </execution> </executions> </plugin> I have this for my surefire-plugin configuration ...

Problem running tests with enabled preview features in surefire and failsafe

时光毁灭记忆、已成空白 提交于 2019-12-05 02:21:17
I'm trying to migrate a project to Java 12, with --enable-preview . I added --enable-preview in compiler settings: <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.0</version> <configuration> <release>12</release> <compilerArgs> <arg>--enable-preview</arg> </compilerArgs> </configuration> </plugin> And also added it in argLine for surefire and failsafe: <properties> <argLine>--enable-preview</argLine> </properties> And do a mvn clean verify results in: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3:test (default-test) on project

How to run junit suite in parallel using maven surefire plugin

旧巷老猫 提交于 2019-12-04 21:23:34
I have a testsuite say JunitTest1 and JunitTest2 as below, @RunWith(Suite.class) @SuiteClasses({ com.sample.test1.class, com.sample.test2.class, com.sample.test3.class, }) public class JunitTest1 { } @RunWith(Suite.class) @SuiteClasses({ com.sample.xxx1.class, com.sample.xxx2.class, com.sample.xxx3.class, }) public class JunitTest2 { } I want to run both the testsuite in parallel but the test class inside the testsuite should run in the specified order. I have added the below plugin in maven pom.xml, <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin<

jacoco coverage per test setup

空扰寡人 提交于 2019-12-04 16:55:52
I'm using jacoco in order to gather code metrics and import them to sonarQube but i was missing details about coverage per test. So after searching about it i came to this tutorial but failed to make it work on my project. here is my pom.xml <properties> <sonarVersion>2.4</sonarVersion> <spring-framework.version>4.0.0.RELEASE</spring-framework.version> <spring-framework.security.version>3.2.5.RELEASE</spring-framework.security.version> <jackson.version>1.9.13</jackson.version> <jacoco.version>0.7.7.201606060606</jacoco.version> <aspectj.version>1.7.4</aspectj.version> <sonar.java

Maven doesn't execute any unit test

自闭症网瘾萝莉.ら 提交于 2019-12-04 15:57:46
问题 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: <modules> <module>../foo-core</module> <module>../foo-bar</module> </modules> <dependencyManagement> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency> <dependency> ... </dependency> </dependencies> </dependencyManagement> <build>

Setting properties via Maven command line

▼魔方 西西 提交于 2019-12-04 09:34:20
问题 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 to pass jvm args via command line to maven?, How to set JVM parameters for Junit Unit Tests?) that touch on this subject but none have the answer I'm looking for. I want to set the property java.util.logging.config.class to some value but I don't

Aggregate surefire reports of maven project hierarchy as XML for eclipse?

纵然是瞬间 提交于 2019-12-04 08:58:56
I have a project hierarchy which built with maven. How can I run all the tests in the whole hierarchy at once from eclipse and easily go to the failures? The maven surefire plugin spews loads of output at the console, but it is tiresome to find the failures there. It also generates XML report files which I can easily open within the normal eclipse JUnit view - but these are many many files and it is difficult to find the files of the failed tests. The maven surefire report plugin allows to aggregate all test results with mvn surefire-report:report-only -Daggregate=true but only in HTML format.

IntelliJ Error when running unit test: Could not find or load main class ${surefireArgLine}

眉间皱痕 提交于 2019-12-04 07:51:39
问题 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: <properties> ... <surefire.argLine /> </properties> <build> <plugins> <plugin> <groupId>com.mysema.maven</groupId> <artifactId>apt-maven-plugin</artifactId> <version>1.1.1</version> <executions> <execution> <goals> <goal>process</goal> </goals> <configuration> <outputDirectory>target/generated-sources/java</outputDirectory>

Maven not running JUnit 5 tests

。_饼干妹妹 提交于 2019-12-04 03:17:08
问题 Im 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: 0 pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">