【发布时间】:2017-07-13 16:50:38
【问题描述】:
我的 pom.xml 有 <systemPropertyVariables> 和 <profiles>。现在,如果我想将它作为 maven 构建运行,我使用-DXXX 用于系统属性变量,-PXXX 用于目标中的配置文件。
现在我想在 Eclipse 中将它作为 JUnit 测试运行。我发现系统属性变量可以在 VMArguments 中给出。
现在的问题是如何访问此配置文件。这是我的个人资料的样子
<profile>
<id>devqa</id>
<build>
<resources>
<resource>
<directory>src/main/resources/devqa</directory>
</resource>
</resources>
</build>
</profile>
我在资源位置有一个文件,我在我的测试中访问它
File testfile = new File(this.getClass().getResource("/config.properties").toURI());
我尝试在 Active Maven Profiles 中提供此功能,但没有成功。如何完成这项工作
【问题讨论】:
-
我必须管理我不明白你的问题。因为你写了你已经完成了
mvn -Pdevqa?这里到底有什么问题?可以更详细地阐述您想要实现的目标吗? -
我可以将项目作为 mvn 项目运行。我现在想将它作为 Junit 测试运行。
-
您在寻找
mvn test吗? -
这是我作为 maven build -f pom.xml test -DbrowserName=chrome -DexecPlatform=native -Pdevqa 运行的设置,这工作得很好。现在的问题是我有一个运行程序文件 @RunWith(Cucumber.class) @CucumberOptions( ) public class WorkbenchSmoke { } 我想用这个运行程序作为 eclipse 中的 Junit 运行项目