Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import working directory for JUnit from maven to IDEA

I am trying to make new developers of my maven project to have as easy start as possible. I am using and recommending IntelliJ IDEA as an IDE for them. I am pretty satisfied with the results of importing the maven project to IDEA. The only complication that I have now is importing of the working directory from the surefire plugin.

In my pom.xml I have the following:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.7.2</version>
    <configuration>
        <workingDirectory>target/work</workingDirectory>
    </configuration>
</plugin>

This works fine when i run the tests from command line (mvn test). When I create new Idea project, the JUnit tests need aditional setup however. The working directory is ignored and I have to manually set it up to be able to run the tests properly.

Do you have any idea how to make Idea import the working directory for JUnit properly?

like image 638
Jiri Peinlich Avatar asked Oct 10 '22 07:10

Jiri Peinlich


1 Answers

Please check a discussion in this issue. There an easy workaround for this problem:

set working directory to $MODULE_DIR$ in the defaults for the run configuration that you will use.

like image 157
CrazyCoder Avatar answered Oct 14 '22 02:10

CrazyCoder