Si je fais ça :
mvn -X \ -Dtest=MojoIntegrationTest \ -Dsurefire.trimStackTrace=false \ -Dsurefire.useFile=false \ clean test
@BeforeEach
public void setUp() {
stuff();
}
@Test
public void testMyApp() {
doApp();
}
et stuff()
o doApp()
explose d'une manière ou d'une autre, je n'obtiens pas la trace complète de la pile, ni dans la console ni dans les fichiers. Soit JUnit5, soit Maven les cache :
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.me.config.plugin.MojoIntegrationTest
Created C:\dev\workspace\gem-config-maven-plugin\target\test-classes\test-project\target
Tests run: 3, Failures: 3, Errors: 0, Skipped: 0, Time elapsed: 2.133 sec <<< FAILURE! - in com.me.config.plugin.MojoIntegrationTest
testFindCommonPropertiesFromDependency Time elapsed: 1.6 sec <<< FAILURE!
java.lang.NullPointerException
at com.me.config.plugin.MojoIntegrationTest.setUp(MojoIntegrationTest.java:168)
testRetrievalOfConfigJar Time elapsed: 0.283 sec <<< FAILURE!
java.lang.NullPointerException
at com.me.config.plugin.MojoIntegrationTest.setUp(MojoIntegrationTest.java:168)
testOutputPropertiesFilesForAllEnvironments Time elapsed: 0.2 sec <<< FAILURE!
java.lang.NullPointerException
at com.me.config.plugin.MojoIntegrationTest.setUp(MojoIntegrationTest.java:168)
Results :
Failed tests:
MojoIntegrationTest.setUp:168 » NullPointer
MojoIntegrationTest.setUp:168 » NullPointer
MojoIntegrationTest.setUp:168 » NullPointer
Tests run: 3, Failures: 3, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.717 s
[INFO] Finished at: 2017-08-21T18:23:05+01:00
[INFO] Final Memory: 31M/389M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project gem-config-maven-plugin: There are test failures.
[ERROR]
[ERROR] Please refer to C:\dev\workspace\gem-config-maven-plugin\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project gem-config-maven-plugin: There are test failures.
Please refer to C:\dev\workspace\gem-config-maven-plugin\target\surefire-reports for the individual test results.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
Caused by: org.apache.maven.plugin.MojoFailureException: There are test failures.
En plus de faire ça :
@BeforeEach
public void setUp() {
try {
stuff();
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
ce que je n'aime vraiment pas, comment puis-je obtenir la trace de la pile ?
Merci.
[UPDATE 1] la configuration pour surefire à partir de mon pom :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<includes>
<include>**/*Test.java</include>
<include>**/*Tests.java</include>
</includes>
<properties>
<excludeTags>integration</excludeTags>
</properties>
</configuration>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider
</artifactId>
<version>1.0.0-M5</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.0.0-M5</version>
</dependency>
</dependencies>
</plugin>
et les dépendances de JUnit5 :
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.0.0-M5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>4.12.0-M5</version>
<scope>test</scope>
</dependency>
Documentation sur Maven surefire ici
[MISE À JOUR 2] : à l'origine, cela n'affectait que mon @BeforeEach
mais maintenant que j'écris des tests, je me rends compte qu'il est en fait partout, c'est-à-dire que mvn et junit5 cachent toutes mes stacktraces.