黄瓜JVM未定义步骤无法解析

时间:2015-09-16 13:53:33

标签: maven selenium cucumber-jvm

我遇到Cucumber JVM无法获取步骤定义的问题。我在Runner文件中有@CucumberOptions。我的功能文件也有@smokeTest标记。 问题仍然存在,对我来说仍然存在。请帮忙!我已经尝试解决这个问题几天了。

Maven和Java版本:

Apache Maven 3.0.4 Java版本:1.6.0_65,供应商:Apple Inc.

项目结构:

  1. 演示 - > src - >测试 - > java - > com.smoke.test - > Runner.java | SmokeTestStepDef.java
  2. 演示 - > src - >测试 - >资源 - > featureDemo.feature
  3. 亚军档案:

    package com.smoke.test;

    import cucumber.api.CucumberOptions;
    import cucumber.api.junit.Cucumber;
    import org.junit.runner.RunWith;
    
    @RunWith(Cucumber.class)
    @CucumberOptions(format={"pretty","html:reports/test-report"},tags= "@smokeTest")
    
    public class Runner {
    }
    

    的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>com.demo</groupId>
        <artifactId>cumcumberdemo</artifactId>
        <version>1.0-SNAPSHOT</version>
    
        <dependencies>
            <dependency>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>selenium-java</artifactId>
                <version>2.41.0</version>
            </dependency>
    
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.12</version>
                <scope>test</scope>
            </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>1.1.7</version>
            <scope>test</scope>
        </dependency>
    
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-jvm</artifactId>
            <version>1.1.7</version>
            <type>pom</type>
        </dependency>
    
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>1.1.7</version>
            <scope>test</scope>
        </dependency>
        </dependencies>
    
    </project>
    

2 个答案:

答案 0 :(得分:1)

featureDemo.feature下移动src/test/resources/com/smoke/test

正如Eugene所说,它看起来像胶水问题,但是根据您的评论,您的项目中似乎还有另一个功能文件隐藏了它实际上无法找到的功能文件的问题

答案 1 :(得分:0)

我认为您还必须在@CucumberOptions中定义胶水路径。这是您的步骤定义所在的位置。它被描述为here