Search code examples
javajunitlog4j2quarkusjunit-jupiter

JUnit tests for Quarkus projects no longer respect log4j2.xml in test/resources


I have a log4j2.xml in the src/test/resources to turn on debug logging during JUnit tests to ensure all code paths are executed. When I try to upgrade to Quarkus 2.7 or higher (I've tried with 2.8 and 2.9), the tests are no longer run with debug logging. This is evident via the jacoco task showing all lines are no longer covered.

Is there a new way I should be going about enabling debug logging during JUnit tests?

Reproducer: service1 in https://github.com/mweber03/quarkus-test

  1. ./gradlew service1:build
  2. ./gradlew service1:jacocoTestCoverageVerification (succeeds)
  3. Change Quarkus version in gradle.properties to 2.7 or higher
  4. Repeat steps 1 and 2 (fails due to code coverage)

Solution

  • You can set the log level in your application.properties. E.g. if you want to set the log level only for your tests you can add following configuration property:

    %test.quarkus.log.level=DEBUG
    

    You can find more information about how to configure logging on the quarkus guides: https://quarkus.io/guides/logging