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

Ron*_*nie 15 java selenium cucumber jenkins cucumber-jvm

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

但是如何通过命令提示符或Jenkins运行它,通过提供特定命令来运行2-3个功能文件(或)2-3个Junit运行程序类来说50个功能文件或JUnit类?

下面是我在Eclipse中如何构建的包浏览器.

在此输入图像描述

下面是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>
Run Code Online (Sandbox Code Playgroud)

Séb*_*nec 20

您可以使用cucumber.options它来运行单个要素文件,该文件将覆盖@CucumberOptions注释中的所有选项:

mvn test -Dcucumber.options="src/test/features/com/perspecsys/salesforce/featurefiles/Account.feature"
Run Code Online (Sandbox Code Playgroud)


use*_*939 6

您可以使用Cucumber.options运行单个功能文件

mvn test -Dcucumber.options="--tags @TestTag"
Run Code Online (Sandbox Code Playgroud)