简体   繁体   English

在IntelliJ Idea中使用Maven依赖项运行Arquillian测试

[英]Running Arquillian tests with Maven dependencies in IntelliJ Idea

When deploying an Arquillian test with Intellij using pom dependencies like: 使用pom依赖项使用Intellij部署Arquillian测试时,例如:

    File[] libs = Maven.resolver().offline()
                                  .loadPomFromFile("pom.xml")
                                  .importRuntimeDependencies()
                                  .resolve().withTransitivity().asFile();

The test run just fine in other IDEs, but with IntelliJ, there is an error that does not let execute the test properly. 该测试可以在其他IDE中正常运行,但是使用IntelliJ时,会出现错误,导致无法正确执行测试。

Go to Edit Configurations (under Run menu), select Defaults branch and then JUnit. 转到“编辑配置”(在“运行”菜单下),选择“默认值”分支,然后选择“ JUnit”。 You can see that Working directory is set to project's directory. 您可以看到工作目录设置为项目目录。 That's why pom.xml could not be found in this location. 这就是为什么在此位置找不到pom.xml的原因。 Fortunately it can be changed either to MAVEN_REPOSITORY or to MODULE_DIR and the latter is exactly what you want. 幸运的是,可以将其更改为MAVEN_REPOSITORY或MODULE_DIR,而后者正是您想要的。 Changing that and saving it in defaults makes the issue above disappear. 更改该设置并将其保存为默认值可使上述问题消失。

Now you can run your tests from IntelliJ even if you have maven dependencies to be included in your @Deployment archive. 现在,即使您将Maven依赖项包含在@Deployment存档中,也可以从IntelliJ运行测试。

As seen here: http://michalostruszka.pl/blog/2012/10/24/arquillian-tests-with-maven-deps-intellij/ 如此处所示: http : //michalostruszka.pl/blog/2012/10/24/arquillian-tests-with-maven-deps-intellij/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM