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

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

但是,我需要使用Runner类运行它们。

我的功能文件在此文件夹中:


  src / test / java / features


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


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


我的跑步者课程也存储在


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


这是Runner类代码:

@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类作为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...() {


因此,不会定义步骤定义。

这与我的测试跑步者的位置有关吗?
我不认为这是自动化文件夹中的定义步骤

谢谢你的帮助

最佳答案

试试这个:不需要主要方法。 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 {

}

10-07 19:03
查看更多