简体   繁体   English

Maven不执行黄瓜中Runner类下配置的测试用例

[英]Maven not executing the test cases configured under runner class in cucumber

Trying to Achieve: 尝试实现:

Run cucumber test cases configured in runner class using Maven. 使用Maven运行在Runner类中配置的黄瓜测试用例。

Issue: 问题:

Configured test cases are not being executed using maven. 尚未使用maven执行已配置的测试用例。

Configured pom.xml file: 配置的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>simplify360Cucumber</groupId>
    <artifactId>s360UIAutomation</artifactId>
    <version>0.0.1</version>
    <packaging>jar</packaging>
    <name>Cucumber-JVM template</name>

    <dependencies>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>1.2.5</version>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-testng</artifactId>
            <version>1.2.5</version>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>1.2.5</version>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-jvm</artifactId>
            <version>1.2.5</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.4.0</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-firefox-driver</artifactId>
            <version>3.4.0</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>htmlunit-driver</artifactId>
            <version>2.24</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        <dependency>
            <groupId>net.masterthought</groupId>
            <artifactId>cucumber-reporting</artifactId>
            <version>3.7.0</version>
        </dependency>
        <dependency>
            <groupId>com.aventstack</groupId>
            <artifactId>extentreports</artifactId>
            <version>3.0.6</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.16</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.16</version>
        </dependency>
        <dependency>
            <groupId>xml-apis</groupId>
            <artifactId>xml-apis</artifactId>
            <version>2.0.2</version>
        </dependency>
        <dependency>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
            <version>2.8.0</version>
        </dependency>
        <!-- <dependency> <groupId>org.apache.maven.surefire</groupId> <artifactId>surefire-junit</artifactId> 
            <version>2.6</version> </dependency> -->
    </dependencies>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.3</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.20</version>
                    <configuration>
                        <includes>
                            <include>**/helpers.RunCukesTest.java</include>
                        </includes>
                        <!-- <excludes> <exclude>**/*RunCukesTest.java</exclude> </excludes> -->
                    </configuration>
                    <!-- <dependencies> <dependency> <groupId>org.apache.maven.surefire</groupId> 
                        <artifactId>surefire-junit</artifactId> <version>2.6</version> </dependency> 
                        </dependencies> -->
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

And the runner class is like this 跑步者班是这样的

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;


@RunWith(Cucumber.class)
@CucumberOptions(
        features = {"classpath:features"},
        plugin = {"pretty", "html:target/cucumber-html-report","json:target/cucumber.json"},
        tags = {"@tag1"},
        glue={"helpers","stepDefinitions"},
//      dryRun = true,
        monochrome = true
        )
public class RunCukesTest{

}

When maven test or maven install are executed from eclipse, test cases are not getting executed but the build is successfull. 当从Eclipse执行maven测试或maven安装时,测试用例没有得到执行,但是构建成功。

import org.apache.log4j.Logger;
import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(plugin = { "pretty", "json:target/Cucumber-report/cucumber.json" },
    features = { "src/test/resources/com/testcases/testsuite" })

public final class CucumberCommandLineTest {

private CucumberCommandLineTest() {
}

static final Logger LOGGER = Logger.getLogger(CucumberCommandLineTest.class.getName());

}

This seems to work for me for running at the CLI : 这对于我在CLI上运行似乎很有效:

C:\Tools\jdk1.7.0_79\bin\java" -cp lib\*;target\62110_Automation_KW_Smoke_Test-1.0.0.0-jar-with-dependencies.jar cucumber.api.cli.Main --glue com.gm.testcases .\src\test\resources\com\testcases\testsuite --tags @TC_185826,@TC_185824 --plugin pretty

in src/main/java and when doing maven clean:install through Eclipse m2e plugin. 在src / main / java中,以及在执行maven clean时:通过Eclipse m2e插件安装。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在我的 cucumber 项目中,为什么我的测试运行程序 class 在执行时被终止(没有抛出任何错误)? - In my cucumber project, why is my test runner class getting terminated( without throwing any error) on executing it? 运行Maven测试时未执行黄瓜测试 - Cucumber tests not executing when running maven test 计划selenium maven项目以执行测试用例 - Scheduling the selenium maven project for executing the test cases junit-Cucumber Runner类在执行测试之前访问一个通用方法 - junit - Cucumber Runner class access a common method before executing tests 执行 Runner class 时找不到多个 Cucumber 标签 - Cant find multiple Cucumber Tags when executing Runner class 尝试在Eclipse Maven项目中配置黄瓜时,流道类出错 - ERROR in runner class while trying to configure cucumber in eclipse maven project maven 未执行我的 cucumber testRunner class 或相关功能文件 - maven not executing my cucumber testRunner class or assocaited feature files 执行org.apache.maven.plugins时缺少必需的类:maven-surefire-plugin:2.14.1:test:org / junit / runner / notification / RunListener - A required class was missing while executing org.apache.maven.plugins:maven-surefire-plugin:2.14.1:test: org/junit/runner/notification/RunListener 如何在不使用 Maven 的情况下从 CLI 运行 Cucumber Test runner - How can I run Cucumber Test runner from CLI without using Maven Jenkins 不执行 Junit 测试类(Maven 项目) - Jenkins not executing Junit Test class (Maven Project)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM