我是 Cucumber 新手,创建了一个示例应用程序 这是它的文件夹结构Cucumber folder structure
我的测试运行器类代码是
@RunWith(Cucumber.class)
@CucumberOptions(features = "Feature/SampleTest.feature",
glue = { "com.testSteps.Test_Steps" })
public class TestRunner {
}
现在我的步骤定义类是 Test_Steps
但如果我在glue属性中提到该类,即 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();
}
请帮助我使用glue属性定义步骤定义类,因为如果我的步骤定义文件夹结构中有多个步骤定义类,那么我如何在glue属性中定位特定的步骤定义类?
最佳答案
@CucumberOptions
中的 glue
参数必须指向一个包,而不是一个类。所以在你的情况下:
glue = {"com.testSteps.", "", ...}
并且您的features
参数应该指向包含所有功能文件的文件夹。它也可以有子目录。
关于java - 如何在Cucumber中的glue属性中提及完全分类的类名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38652048/