m2e integration with logging manager
I have this in my pom.xml:
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${v.plugin.surefire}</version>
<configuration>
<systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</plugin>
When running Junit tests of the entire project (mvn test), the logging within all test classes works as expected. Eclipse uses the systemPropertyVariables defined in the Surefire plugin.
However, when executing only one test case (e.g. a method annotated with @Test) and right-clicking on a test file ("Run as->Junit Test"), the logging doesn't work and I get this error the console:
ERROR:
The LogManager accessed before the "java.util.logging.manager" system property was set to "org.jboss.logmanager.LogManager".
Results may be unexpected.
To solve this issue, I need to
Right click on unit test file -> Run As -> Run Configuration -> JUnit -> Tab "Arguments"
and add the below line in "VM arguments"-section:
-Djava.util.logging.manager=org.jboss.logmanager.LogManager
With this workaround, logging for this file works. However, it is cumbersome to add this line to every Junit test class.
Would be nice if m2e took systemPropertyVariables into account when executing test files from the IDE (e.g. when right-clicking on a test file ("Run as->Junit Test")).
workaround: add the system property to the JRE definition (of the JRE used in the test) in Preferences>Installed JREs instead