如何在Cucumber的glue属性中提及完全分类的类名

时间:2016-07-29 06:38:14

标签: java cucumber cucumber-junit cucumber-java

我是Cucumber的新手并创建了一个示例应用程序 以下是Cucumber folder structure

的文件夹结构

我的测试跑步者类代码是

@RunWith(Cucumber.class)    
@CucumberOptions(features = "Feature/SampleTest.feature",     
                 glue = { "com.testSteps.Test_Steps" })
public class TestRunner {

}

现在我的步骤定义类是Test_Steps但是如果我在胶水属性中提到该类,即glue = { "com.testSteps.Test_Steps" },则测试运行器无法找到测试定义类。在我的控制台输出下面

You can implement missing steps with the snippets below:

@Given("^User is on Home Page$")
public void user_is_on_Home_Page() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

请帮我用胶水属性定义步骤定义类,因为如果我的步骤定义文件夹结构中有多个步骤定义类,那么如何在胶合属性中定位特定的步骤定义类?

1 个答案:

答案 0 :(得分:1)

glue中的@CucumberOptions参数必须指向包,而不是类。所以在你的情况下:

glue = {"com.testSteps.", "", ...}

features参数应指向包含所有要素文件的文件夹。它也可以有子目录。