硒测试应该保存在单独的项目中

问题描述 投票:1回答:1

我有一个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运行此测试以及其他集成/单元测试)

selenium jenkins
1个回答
0
投票

当你使用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 SuiteMaven Test
  • 启动Jenkins并浏览到Manage Jenkins - > Configure System
  • 向下滚动到JDK -> JDK installations并确保JAVA_HOME设置为C:\path\to\jdk1.8.0_144。取消选中Install automatically
  • 向下滚动到Maven -> Maven installations并提供Name作为MAVEN_HOMEMAVEN_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>	
  • 通过Jenkins构建您的项目

根据您的具体问题In order to have this running do I have to extract the selenium tests to other project ?答案是否定的。

方案:

  • 如果你想同时执行Suites IntegrationSelenium,这个设置就是你的。
  • 如果你想分别执行任何一个qazxsw poi,将Suites和qazxsw poi套件分成不同的Integration并打开和关闭Selenium的执行。
© www.soinside.com 2019 - 2024. All rights reserved.