surefire

Setting timezone for maven unit tests on Java 8

廉价感情. 提交于 2019-11-28 06:52:29
How do I set the timezone for unit tests in maven surefire on Java 8? With Java 7 this used to work with systemPropertyVariables like in the following configuration, but with Java 8 the tests just use the system timezone. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <systemPropertyVariables> <user.timezone>UTC</user.timezone> </systemPropertyVariables> Why is that, and how do I fix it? Wouter Coekaerts Short answer Java now reads user.timezone earlier, before surefire sets the properties in systemPropertyVariables . The

Using JUnit RunListener with Maven

天涯浪子 提交于 2019-11-28 01:56:42
问题 I want to use my own RunListener on my unit tests. So I've created the following class: public class MyRunListener extends RunListener { public MyRunListener() { System.out.println("Creation of Run Listener..."); } @Override public void testStarted(Description description) throws Exception { System.out.println("A Test is going to start"); } } Now, in my pom.xml : <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <properties>

Logging level under maven surefire

老子叫甜甜 提交于 2019-11-28 00:39:27
I'm unable to adjust java logging's logging level. I'm using maven surefire (mvn test), and trying to adjust from the default INFO to e.g. FINEST. I have logging.properties file under src/test/resources/logging.properties after compile, i see under target/test-classes, i see a logging.properties file with the intended config: java.util.logging.ConsoleHandler.level=FINEST javax.enterprise.system.container.ejb.level=FINE ... however the console output from glassfish only have INFO / SEVERE level messages. Where did I go wrong? or is this another pain in the butt thing with maven? martin You need

Maven surefire plugin fork mode

ぃ、小莉子 提交于 2019-11-27 20:45:05
问题 By default maven surefile plugin run tests in isolated (forked) environment. You can override this behavior with following configuration: <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <forkMode>never</forkMode> </configuration> </plugin> </plugins> </build> If you need to debug your tests you should to use this configuration snippet. Or you could simply run maven build the following way: $ mvn -Dmaven

Is there a decent HTML Junit report plugin for Maven?

£可爱£侵袭症+ 提交于 2019-11-27 17:51:05
I find the surefire-report plug-in very unsuitable to my working style. I clean the project all the time and I don't want to spend 5 min to rebuild the whole site every time I want to look at the test report in my browser. If I type mvn surefire-report:report-only , the generated report is too ugly and barely readable. What I'm looking for is something like ant's JUnitReport task. Is there one available out there already? Pascal Thivent Indeed, generating the whole site at each build is clearly not an option. But the problem is that mvn surefire-report:report-only doesn't create the the css/*

Running all tests from a @Category using Maven

不想你离开。 提交于 2019-11-27 16:45:00
问题 I want to run only a subset of my unit tests, the ones defined by a specific @Category . So I read several SO questions, such as this one (which is exactly what I am looking for), and also this one. The solution of my problem seems to be provided by the ClasspathSuite project. So I started to write the NewTest and OldTest interfaces that will define my test categories. Then, I created the AllTests suite: @RunWith(ClasspathSuite.class) public class AllTests { } After that, I created a

Making Maven run all tests, even when some fail

浪子不回头ぞ 提交于 2019-11-27 16:40:36
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 help. How do I make maven run all tests? despot From the documentation: -fae , --fail-at-end Only fail the build afterwards; allow all non-impacted builds to continue -fn , --fail-never NEVER fail the build, regardless of project result So if you are testing one module than you are safe using -fae . Otherwise, if you have multiple modules, and if you want

Surefire is not picking up Junit 4 tests

北城以北 提交于 2019-11-27 12:20:40
For some reason I cannot get Maven 2 Surefire plugin to execute JUnit 4 test class. public class SimpleTest { @org.junit.Test public void simple() { System.out.println("foo"); } } However if I change this class to be JUnit-3 like, such as public class SimpleTest extends junit.framework.TestCase { public void testBar() { System.out.println("bar"); } @org.junit.Test public void simple() { System.out.println("foo"); } } then it gets executed. Here's what I've done: verified Maven version: Apache Maven 2.2.1 (r801777; 2009-08-06 20:16:01+0100) verified Surefire version: followed this advice

Make maven's surefire show stacktrace in console

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-27 09:55:31
问题 I'd like to see the stacktrace of unit tests in the console. Does surefire support this? 回答1: You can use the following command to see the stack trace on console instead of report files in the target/surefire-reports folder: mvn -Dsurefire.useFile=false test 回答2: A related problem that I found is that surefire in recent versions apparently sets trimStackTrace to true by default (rendering most stack trace in failed tests useless), which is quite inconvenient. Setting -DtrimStackTrace=false or

Is there a way to skip only a single test in maven?

∥☆過路亽.° 提交于 2019-11-27 09:39:56
问题 I would like to skip only a single test while launching mvn install . Is there a way to do that ? 回答1: With junit 4, I add an @Ignore annotation when I want to do that. This would work for you, unless you want to only sometimes ignore the test, or only ignore it when the build runs from maven. If this is the case, then I would ask "Why?" Tests should be consistent, they should be portable, and they should always pass. If a specific test is problematic I would consider re-writing it, removing