Ric*_*rth 10 integration-testing maven cucumber-jvm cucumber-junit
我有以下项目结构:
MyProject
--src
--test
--acceptance
--step_definitions
--features
--unit
Run Code Online (Sandbox Code Playgroud)
我希望能够在测试/单元中声明的单元测试中分别在Maven中运行我的黄瓜测试(在测试/验收中),以便它们可以在不同的CI构建计划中运行等.我正在使用cucumber-junit所以每个验收测试的"跑步者"都是用JUnit编写的.
这可能吗?
Pet*_*vic 13
这可能吗?
对的,这是可能的.我相信你应该将你的单位与接受/整合测试分开:
稍微修改文件夹结构对于这两个,把你的集成测试文件的标准位置的src/it:
MyProject/
src/main/java/ (SUT)src/test/ (单元测试代码)
java/resources/src/it/ (验收/整合测试)
java/ (步骤定义)resources/ (功能文件)此外,通过设计,不同的Maven插件用于单元和集成测试:
maven-surefire-pluginmaven-failsafe-plugin您还必须绑定执行maven-failsafe-pulgin.要单独运行集成测试,您可以定义新的配置文件:
<profiles>
<profile>
<id>acceptance-tests</id>
<build>
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.12</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
Run Code Online (Sandbox Code Playgroud)
接受测试可以在以后使用:
mvn clean verify -Pacceptance-tests
Run Code Online (Sandbox Code Playgroud)
如需完整样本,我建议您关注http://www.weblogism.com/item/334/integration-tests-with-cucumber-jvm-selenium-and-maven
| 归档时间: |
|
| 查看次数: |
11195 次 |
| 最近记录: |