gpt4 book ai didi

java - Serenity Screenplay 从 CLI 运行测试

转载 作者:行者123 更新时间:2023-12-01 18:36:53 25 4
gpt4 key购买 nike

有没有办法通过 CLI 执行 Serenity Screenplay 测试?我尝试发出 mvn test -Dcucumber.options="list of test files" 命令,但 Maven 没有执行任何操作。
目前,这是我在 src/test/java 下的主类

import cucumber.api.CucumberOptions;
import net.serenitybdd.cucumber.CucumberWithSerenity;
import org.junit.runner.RunWith;

@RunWith(CucumberWithSerenity.class)
@CucumberOptions(features = "src/test/resources/features/NuovoClienteCreazione.feature", format = {"pretty", "html:target/Destination"})
public class CucumberMain {
}

此外,pom.xml 文件具有以下内容

<?xml version="1.0" encoding="UTF-8"?>
<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>EPP</groupId>
<artifactId>AutomationTesting</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<cucumber.version>1.2.5</cucumber.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>



<dependencies>

<!-- region: Cucumber e Serenity -->

<!-- https://mvnrepository.com/artifact/net.serenity-bdd/serenity-core -->
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>2.0.89</version>
</dependency>

<!-- https://mvnrepository.com/artifact/net.serenity-bdd/serenity-cucumber -->
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-cucumber</artifactId>
<version>1.9.48</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.sql2o/sql2o -->
<dependency>
<groupId>org.sql2o</groupId>
<artifactId>sql2o</artifactId>
<version>1.6.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>


<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc</artifactId>
<version>7</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/ojdbc7.jar</systemPath>
</dependency>

<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>


<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-screenplay</artifactId>
<version>2.0.89</version>
</dependency>

<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-screenplay-webdriver</artifactId>
<version>2.0.89</version>
</dependency>

<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-junit</artifactId>
<version>2.0.89</version>
<scope>test</scope>
</dependency>

<!-- endregion -->



<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>3.141.59</version>
</dependency>

<!-- endregion -->


<!-- region: Drivers di Selenium -->

<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-firefox-driver -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>3.6.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-ie-driver -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-ie-driver</artifactId>
<version>3.6.0</version>
</dependency>

</dependencies>


</project>

有人在使用 Serenity Screenplay 时遇到过这样的问题并且能够从 CLI 执行测试吗?

最佳答案

最终我发现我必须首先设置 Failsafe 插件,然后使其与 CucumberMain 类进行通信。然后,从 CLI 中,使用我想要执行的测试列表执行 mvn verify 或 mvn test 就成功了

关于java - Serenity Screenplay 从 CLI 运行测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60016975/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com