<properties>
<failsafe.rerunFailingTestsCount>2</failsafe.rerunFailingTestsCount>
<surefire.rerunFailingTestsCount>2</surefire.rerunFailingTestsCount>
</properties>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<includes>
<include>**/*.java</include>
</includes>
<argLine>-Xmx512m</argLine>
<systemPropertyVariables>
<webdriver.driver>${webdriver.driver}</webdriver.driver>
</systemPropertyVariables>
<systemProperties>
<webdriver.driver>${webdriver.driver}</webdriver.driver>
<surefire.rerunFailingTestsCount>${surefire.rerunFailingTestsCount}</surefire.rerunFailingTestsCount>
<surefire.rerunFailingTestsCount>${surefire.rerunFailingTestsCount}</surefire.rerunFailingTestsCount>
</systemProperties>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
在执行上述命令后,我希望失败的场景应该再次执行,但它没有重新执行
2.使用cucumber格式化程序生成rerun.txt并执行它
按照另一个解决方案,我使用cucumber格式化程序生成rerun.txt。得到错误的场景将在rerun.txt中列出,然后由第二个运行类拾取并执行那些失败的场景。
我能够成功地生成rerun.txt,但是第二个运行程序类既没有得到执行,也没有得到任何类型的错误
Runnerclass 1
@RunWith(CucumberWithSerenity.class)
@CucumberOptions(
features = "src/test/resources/features",
tags = "@RunThis",
monochrome = true
,plugin = { "json:target/cucumber-report-composite.json", "pretty",
"html:target/cucumber/","rerun:target/rerun.txt" })
public class AcceptanceTest {
}
@RunWith(CucumberWithSerenity.class)
@CucumberOptions(strict = true,
glue = { "src/test/resources/features" },
features = { "@target/rerun.txt" },
plugin = { "json:target/cucumber-report-composite.json", "pretty",
"html:target/cucumber/"})
public class AcceptanceTest2 {
}
<dependency>
<groupId>com.github.mkolisnyk</groupId>
<artifactId>cucumber-runner</artifactId>
<version>1.3.1</version>
</dependency>
@RunWith(CucumberWithSerenity.class)
@ExtendedCucumberOptions(jsonReport = "target/cucumber.json",
retryCount = 3,
jsonUsageReport = "target/cucumber-usage.json",
outputFolder = "target")
@CucumberOptions(
features = "src/test/resources/features",
tags = "@RunThis",
monochrome = true
,plugin = { "json:target/cucumber-report-composite.json", "pretty",
"html:target/cucumber/","rerun:target/rerun.txt" })
public class AcceptanceTest {
}
完整的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>GROUPNAME</groupId>
<artifactId>ARTIFACTNAME</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Serenity project using Cucumber and WebDriver</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<failsafe.rerunFailingTestsCount>2</failsafe.rerunFailingTestsCount>
<surefire.rerunFailingTestsCount>2</surefire.rerunFailingTestsCount>
<serenity.version>1.6.3</serenity.version>
<serenity.cucumber.version>1.5.9</serenity.cucumber.version>
<serenity.maven.version>1.2.1</serenity.maven.version>
<webdriver.driver>chrome</webdriver.driver>
</properties>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray</name>
<url>http://jcenter.bintray.com</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray-plugins</name>
<url>http://jcenter.bintray.com</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<!-- <dependency> <groupId>net.serenity-bdd.maven.plugins</groupId> <artifactId>serenity-maven-plugin</artifactId>
<version>1.5.0-rc.1</version> </dependency> -->
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>${serenity.version}</version>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-cucumber</artifactId>
<version>${serenity.cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.25</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>com.googlecode.lambdaj</groupId>
<artifactId>lambdaj</artifactId>
<version>2.3.3</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20171018</version>
</dependency>
<dependency>
<groupId>com.qpid.automation</groupId>
<artifactId>AutomationToolKit</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.github.mkolisnyk</groupId>
<artifactId>cucumber-runner</artifactId>
<version>1.3.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<!-- <skip>true</skip> -->
<argLine>-Dfile.encoding="UTF-8"</argLine>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<includes>
<include>**/*.java</include>
</includes>
<argLine>-Xmx512m</argLine>
<systemPropertyVariables>
<webdriver.driver>${webdriver.driver}</webdriver.driver>
</systemPropertyVariables>
<systemProperties>
<webdriver.driver>${webdriver.driver}</webdriver.driver>
<surefire.rerunFailingTestsCount>${surefire.rerunFailingTestsCount}</surefire.rerunFailingTestsCount>
<surefire.rerunFailingTestsCount>${surefire.rerunFailingTestsCount}</surefire.rerunFailingTestsCount>
</systemProperties>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- Generate the test reports after the integration tests -->
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>${serenity.version}</version>
<executions>
<execution>
<id>serenity-reports</id>
<phase>post-integration-test</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
我可以使用下面的代码实现重新运行。
@RunWith(CucumberWithSerenity.class)
@CucumberOptions(
features = "src/test/resources/features", tags = "@Smoke1",
monochrome = true,
plugin = {"pretty", "html:target/cucumber-reports", "json:target/cucumber.json","rerun:rerun.txt"})
public class AcceptanceTest {
}
我只执行下面的命令,在上面的插件(@cucumberoptions)(@cucumberoptions)中添加重新运行后
mvn clean verify -Dcucumber.options="--tags @Smoke1"
并自动重新执行失败的场景。我不需要编写另一个运行类并手动运行它。
<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>GROUPID</groupId>
<artifactId>ARTIFACTID</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Serenity project using Cucumber and WebDriver</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<serenity.version>1.9.2</serenity.version>
<serenity.cucumber.version>1.9.3</serenity.cucumber.version>
<serenity.maven.version>1.8.21</serenity.maven.version>
<webdriver.driver>chrome</webdriver.driver>
</properties>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray</name>
<url>http://jcenter.bintray.com</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray-plugins</name>
<url>http://jcenter.bintray.com</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>${serenity.version}</version>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-cucumber</artifactId>
<version>${serenity.cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.25</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>com.googlecode.lambdaj</groupId>
<artifactId>lambdaj</artifactId>
<version>2.3.3</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20171018</version>
</dependency>
<dependency>
<groupId>com.qpid.automation</groupId>
<artifactId>AutomationToolKit</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<!-- <skip>true</skip> -->
<argLine>-Dfile.encoding="UTF-8"</argLine>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<includes>
<include>**/*.java</include>
</includes>
<argLine>-Xmx512m</argLine>
<systemPropertyVariables>
<webdriver.driver>${webdriver.driver}</webdriver.driver>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- Generate the test reports after the integration tests -->
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>${serenity.version}</version>
<executions>
<execution>
<id>serenity-reports</id>
<phase>post-integration-test</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
我有一个示例项目,其中使用了Maven、TestNg和Cucumber。我使用testrunner类运行测试。 我创建了一个包含两个方案的功能文件,但两个方案都失败了。我有两个具有不同功能文件的测试运行者类 - 1。特征文件指向所有功能,2。指向仅失败的方案。 当我尝试重新运行场景时,它只运行一个场景。 1- 请告知如何执行所有失败的方案。
我用Cucumber/Selenide编写自动化测试,我想重新运行失败的场景。 这是我项目的一部分,只有两个小测试(一个失败)来演示行为:https://github.com/mtpx/cucumberRerun 我阅读了如何使用cucumber重新运行失败的场景?和https://medium.com/@belek.bagishbekov/how-to-rerun-failed-test-cas
我正在使用SeleniumWebDriver(2.53.0版)的Java实现对web应用程序运行一些自动化测试。测试使用Cucumber的Java实现(版本1.2.3)以行为驱动测试格式编写。我使用Maven(3.3.9版)导入我的所有依赖项,并构建和运行测试。使用cucumber标签将测试分为不同类别。例如,我可以使用以下命令从命令行运行一类标有@JohnnyBravo的测试: 在做了一些研究后
我想自动重试失败的测试,以提高测试的可靠性,类似于 Junit 中的 TestRule,我希望能够灵活地在测试周围插入逻辑,以便实现重试循环: > 我正在使用Cucumber-JVM,需要一个涉及Java或Gradle的解决方案 我通过Gradle javaexec尝试了以下cucumber选项: //--format pretty--format rerun--out tmp/rerun.txt
我正在使用 jvm cucumber并行插件,并希望重新运行我失败的测试用例。需要在 文件中进行哪些更改。
我正在尝试执行第二轮仅运行失败的场景,以避免由于环境/网络/测试不稳定而出现错误警报。我想知道是否有办法只运行一个maven命令来执行以下操作:1。运行my runner在其配置2中包含的所有方案。制作cucumber。此运行3的json报告。创建失败场景的列表4。运行失败场景列表5。根据第二次运行中失败测试的结果,更改第一次运行中创建的报告的结果,以便在最后,只有在两次运行中失败的场景被标记为失
我已经建立了一个cucumberjava硒项目,我想在我的管道中添加重新运行阶段。使用运行器AllTestRunner中的@rerun插件.java我能够创建一个仅失败测试的重新运行.txt并使用maven-surefire-plugin,我创建了一个第二个运行器FailedRunner.java用于自动执行,仅失败的测试。 问题是FailedRunner.java不仅执行失败的测试,还执行All
我是Serenity和BDD的新手。我有一个基于Serenity Cucumber和Page based模型的小型演示项目。项目结构如下: 登录和注销功能大约有8种情况。 我希望能够并行运行功能文件。实现这一点的最简单和最有效的方法是什么? 到目前为止我已经 > 为每个功能创建了单独的 Runner 类,然后使用故障安全或万无一失的插件 - 这是我不想要的,因为我不希望每个功能文件都有新的运行器。