我有一个Java Web应用程序(Maven),我有一些Selenium测试。测试框架是Junit 4.x. 我也使用Jenkins进行CI。现在我的所有测试(集成+ selenium)都保存在项目的src / test文件夹下。(经典的maven结构)
由于Jenkins无法运行selenium测试(它没有配置为执行此操作 - 我在没有图形界面的Linux机器上运行,在这种情况下的解决方案似乎有点笨拙,但我在考虑运行硒服务器,以便我可以在Windows从机上运行所有这些测试)我必须手动“从执行中删除selenium测试”,否则我将有很多失败的测试。
我想要完成的是一个场景: 1.提交SVN 詹金斯创造了一个构建 3.运行测试,如果没有问题,请转到下一步,否则,停止 4.将应用程序部署到应用服务器 5.在Jenkins中作为post build脚本运行针对该部署的selenium测试。
为了让这个运行,我必须将selenium测试提取到其他项目吗? (为了避免Jenkins运行此测试以及其他集成/单元测试)
当你使用Maven并且你说kept under the src/test folder of the project
听起来就是Perfecto。
你没有在你的问题中提到为什么Jenkins cannot run selenium tests (it is not configured to do this)
。在你的问题的后面你提到了Run the tests
,假设你正在使用TestNG,它只是Jenkins执行Maven的pom.xml的一步配置,它将调用* testng.xml,如下所述:
Automated Test Suite
正确执行TestNG Suite
和Maven Test
。Manage Jenkins
- > Configure System
JDK -> JDK installations
并确保JAVA_HOME
设置为C:\path\to\jdk1.8.0_144
。取消选中Install automatically
Maven -> Maven installations
并提供Name
作为MAVEN_HOME
和MAVEN_HOME
作为C:\path\to\apache-maven-3.3.3
。取消选中Install automatically
JDK -> JDK installations
并确保Local Maven Repository
设置为Default(~/.m2/repository)
。New Item
作为Maven project
。Build
部分并提供Root POM
作为pom.xml
的绝对路径,例如C:\Users\<user_name>\LearnAutmation\maven.jenkins\pom.xml
Goals and options
设为clean install
testng.xml
移动到\ProjectWorkSpace\src\main\resources\testng.xml
和你的pom.xml
你必须提到testng.xml
的位置如下:<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
根据您的具体问题In order to have this running do I have to extract the selenium tests to other project ?
答案是否定的。
Suites
Integration
和Selenium
,这个设置就是你的。Suites
和qazxsw poi套件分成不同的Integration
并打开和关闭Selenium
的执行。