Log4j configuration JUnit vs. Scalatest in IntelliJ

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Log4j configuration JUnit vs. Scalatest in IntelliJ

Ufuk Celebi-2
Hey Flinksters and IntelliJers, ;-)

the tests resources directory of each Maven module contains a log4j-test.properties files, which gets picked via the classpath by JUnit tests, but not Scalatest. Instead Scalatest picks up log4j.properties, but JUnit doesn't.

It works when I specify the file via the log4j.configuration property as a VM argument in the default run config for Scalatest.

Is there another solution? And why is it behaving like this?

– Ufuk
Reply | Threaded
Open this post in threaded view
|

Re: Log4j configuration JUnit vs. Scalatest in IntelliJ

Till Rohrmann
The reason for this behaviour is the following:

The log4j-test.properties is not a standard log4j properties file. It is
only used if it is explicitly given to the executing JVM by
-Dlog4j.configuration. The parent pom defines for the surefire plugin a
corresponding argument line with this option. Intellij uses these maven
settings for executing Java JUnit tests. For the scala tests which are
executed with JUnitRunner, these settings are not used. I don't know why
this is the case for the scala tests. But in order to get consistent
behaviour you can turn off the maven settings import by unticking Build,
Execution, Deployment -> Build Tools -> Maven -> Running Tests -> argLine
in the IntelliJ settings.

On Wed, Feb 25, 2015 at 2:02 PM, Ufuk Celebi <[hidden email]> wrote:

> Hey Flinksters and IntelliJers, ;-)
>
> the tests resources directory of each Maven module contains a
> log4j-test.properties files, which gets picked via the classpath by JUnit
> tests, but not Scalatest. Instead Scalatest picks up log4j.properties, but
> JUnit doesn't.
>
> It works when I specify the file via the log4j.configuration property as a
> VM argument in the default run config for Scalatest.
>
> Is there another solution? And why is it behaving like this?
>
> – Ufuk
Reply | Threaded
Open this post in threaded view
|

Re: Log4j configuration JUnit vs. Scalatest in IntelliJ

Ufuk Celebi-2

On 25 Feb 2015, at 16:35, Till Rohrmann <[hidden email]> wrote:

> The reason for this behaviour is the following:
>
> The log4j-test.properties is not a standard log4j properties file. It is
> only used if it is explicitly given to the executing JVM by
> -Dlog4j.configuration. The parent pom defines for the surefire plugin a
> corresponding argument line with this option. Intellij uses these maven
> settings for executing Java JUnit tests. For the scala tests which are
> executed with JUnitRunner, these settings are not used. I don't know why
> this is the case for the scala tests. But in order to get consistent
> behaviour you can turn off the maven settings import by unticking Build,
> Execution, Deployment -> Build Tools -> Maven -> Running Tests -> argLine
> in the IntelliJ settings.

Thanks. Makes more sense now. :-)