【发布时间】:2016-07-23 11:06:02
【问题描述】:
我的 selenium 测试套件运行良好。我正在混合使用黄瓜、Selenium 和 Java(Maven 项目)以及 Jenkins 的运行套件。
现在我想从 Jenkins 运行我的整个测试套件并行运行(5 个测试应该并行运行)。我已经编写了这样的代码,每个测试都在单独的线程中运行。
谁能告诉我需要在目标和选项中配置哪些参数? 还有什么其他方法可以实现吗?
我的 junit 类如下所示: 请在下面找到我的junit类:
@RunWith(Cucumber.class)
@CucumberOptions(
features="classpath:",
glue={"stepdefinitions","helpers"},
plugin = {"pretty", "html:target/cucumber","json:target/cucumber/cucumber.json"}
)
public class RunnerTest { }
我的 pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>LinenHousePOC</groupId>
<artifactId>LinenHousePOC</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<thread.count.methods>3</thread.count.methods>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.4</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>1.2.4</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.4</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-testng</artifactId>
<version>1.1.5</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.1</version>
</dependency>
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>2.41.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<parallel>methods</parallel>
<perCoreThreadCount>false</perCoreThreadCount>
<useUnlimitedThreads>true</useUnlimitedThreads>
<threadCountMethods>${thread.count.methods}</threadCountMethods>
<forkCount>1</forkCount>
<reuseForks>true</reuseForks>
</configuration>
</plugin>
</plugins>
</build>
</project>
【问题讨论】:
-
您现在如何启动测试?如果您使用的是标准 maven 插件,它应该与 Jenkins 配置无关。
-
你的测试框架是什么? junit?testng?你是如何让它们平行的?我这边有很多问题,还有很多可能的答案;),你能发布你的整个技术栈
-
我正在使用 junit 运行我的测试套件。我只有一个跑步者档案。在 Jenkins 中,我将作业配置为 maven 项目,指定源路径,然后在目标中,我给出了“干净的测试 -Dbrowser=$BrowserName”,它一个接一个地运行整个套件。但我想并行执行这些测试。
-
我的一个朋友告诉我们,如果我们指定 -Pparallel 标记和线程数,它应该并行运行,但我不确定。
标签: java maven selenium jenkins