Cucumber Runner Class 不是 运行 步骤定义

Cucumber Runner Class not running Step Definitons

我正在用 Cucumber 和 Java 编写自动化测试。

我可以通过右键单击我的功能文件来 运行 步骤定义,然后 运行 将其作为 Cucumber 功能,所有步骤都成功通过。

但是,我需要 运行 他们使用 Runner Class。

我的特征文件在这个文件夹中:

src/test/java/features

我的步骤定义在这个文件夹中:

src\test\java\com\abc\commercial\def\automation

我的 Runner Class 也存储在

src\test\java\com\abc\commercial\def\automation

这是跑步者 Class 代码:

@RunWith(Cucumber.class)
@CucumberOptions(
    plugin = {"progress",
            "html:build/report/html",
            "junit:build/report/junit/cucumber-report.xml",
            "json:build/report/json/cucumber-report.json"
    },
    glue = {"src\test\java\com\abc\commercial\def\automation"},
    features = {"src/test/java/features"}
    )
public class QARunner {

public static void main(String[] args) {
    // TODO Auto-generated method stub

    }
}

当我 运行 Runner Class 作为 JUnit 测试时,我在控制台中收到以下响应:

UUUUUUUUU

Undefined scenarios:
src/test/java/features/US46052
src/test/java/features/postFeatures.feature:43 # As the

2 Scenarios (2 undefined)
9 Steps (9 undefined)
0m0.303s


You can implement missing steps with the snippets below:

@Given("the Application...")
public void the_Application...() {

因此未拾取步骤定义。

和我的测试运行ner所在的位置有关系吗? 我认为它不会在 automation 文件夹

中获取步骤定义

感谢您的帮助

试试这个:不需要 main 方法。 glue 选项应为包样式。

@RunWith(Cucumber.class)
@CucumberOptions(
    plugin = {"progress",
            "html:build/report/html",
            "junit:build/report/junit/cucumber-report.xml",
            "json:build/report/json/cucumber-report.json"
    },
    glue = {"com.abc.commercial.def.automation"},
    features = {"src/test/java/features"}
    )
public class QARunner {

}