如何将JUnit的工作目录从maven导入到IDEA [英] How to import working directory for JUnit from maven to IDEA

查看:434
本文介绍了如何将JUnit的工作目录从maven导入到IDEA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让我的maven项目的新开发人员尽可能轻松地开始。我正在使用并推荐IntelliJ IDEA作为它们的IDE。我对将maven项目导入IDEA的结果非常满意。我现在唯一的复杂功能是从surefire插件导入工作目录。

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.

在我的pom.xml中,我有以下内容:

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>

当我从命令行(mvn test)运行测试时,这工作正常。
当我创建新的Idea项目时,JUnit测试需要aditional设置。工作目录被忽略,我必须手动设置它才能正常运行测试。

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.

你知道如何让Idea导入工作目录吗?适用于JUnit?

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

推荐答案

请查看此问题这个问题有一个简单的解决方法

默认值中的工作目录设置为 $ MODULE_DIR $ ,以用于您将使用的运行配置。

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

这篇关于如何将JUnit的工作目录从maven导入到IDEA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆