gpt4 book ai didi

java - 如何通过命令提示符和使用 Maven 的 jenkins 运行单个 cucumber 功能文件?

转载 作者:搜寻专家 更新时间:2023-10-30 21:00:00 25 4
gpt4 key购买 nike

我对 Cucumber/Maven 有点陌生,因此需要有关运行测试用例的帮助。我使用 Cucumber 和 Selenium 在 eclipse 中开发了一个自动化套件。要运行特定的功能文件/Junit 运行器类,我在 Eclipse 中右键单击文件并运行它。

但是我如何通过命令提示符或 Jenkins 运行它,给出特定的命令来运行 2-3 个特征文件(或)50 个特征文件或 JUnit 类中的 2-3 个 Junit 运行器类?

下面是我在 Eclipse 中构建的包资源管理器。

enter image description here

下面是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>com.perspecsys</groupId>
<artifactId>salesforce</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>salesforce</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</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.1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>1.1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.48.2</version>
</dependency>

</dependencies>
</project>

最佳答案

您可以使用 cucumber.options 运行单个功能文件,这将覆盖您在 @CucumberOptions 注释中的所有选项:

mvn test -Dcucumber.options="src/test/features/com/perspecsys/salesforce/featurefiles/Account.feature"

编辑(2021 年 6 月):后续版本删除了 cucumber.options 构造并替换了它。现在实现相同结果的一种方法是使用标签。在您的功能文件顶部放置一个标签(示例 @feature_file_name),然后运行以下命令:

mvn test -Dcucumber.filter.tags='@feature_file_name'

关于java - 如何通过命令提示符和使用 Maven 的 jenkins 运行单个 cucumber 功能文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34772622/

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