eclipse.platform icon indicating copy to clipboard operation
eclipse.platform copied to clipboard

m2e integration with logging manager

Open nimo23 opened this issue 1 year ago • 1 comments

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")).

nimo23 avatar Apr 18 '24 21:04 nimo23

workaround: add the system property to the JRE definition (of the JRE used in the test) in Preferences>Installed JREs instead

Bananeweizen avatar Apr 20 '24 13:04 Bananeweizen