Running JUnit tests in IDEA does not respect/consume pom.xml configuration of maven-surefire-plugin
已回答
In pom.xml I have:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<systemProperties>
<property>
<name>catalina.home</name>
<value>${project.build.directory}</value>
</property>
</systemProperties>
</configuration>
</plugin>
and in log4j.xml I have:
<appender name="file" class="org.apache.log4j.RollingFileAppender">
...
<param name="file" value="${catalina.home}/logs/mdht-restlet.log" />
...
</appender>
However, despite having logs/mdht-restlet.log off the root of my project, log4j informs me that
log4j:ERROR setFile(null,false) call failed.
java.io.FileNotFoundException: /logs/mdht-restlet.log (No such file or directory)
Is this just not supposed to work? Is there some other way to trick IntelliJ into making this work?
Thanks!
请先登录再写评论。
Hello Russel,
Will it work if you use "systemPropertyVariables" instead: http://maven.apache.org/surefire/maven-surefire-plugin/examples/system-properties.html
It now works, though the log file isn't where I wanted it to be, but this is my fault by choosing the wrong Maven/system property. After changing the maven-surefire-plugin configuration in pom.xml to this:
I'm now getting:
And the last line above, which goes to the console, also goes to file mdht-restlet/target/logs/mdht-restlet.log. I see this as success, though I have something to fix on my part.
Thank you very much, Yaroslav!