在如下定义的项目结构中,
当我从RunCukesTest.java using RunAs --> JUnit Test,
跑步时跑步者无法找到步骤定义
单击“查找步骤”时,打开正确的文件。无法理解问题所在,因为代码几天后就运行了。文件从这里下载
https://drive.google.com/open?id=0B4SgyzyvwKhiVTRmRDZuNXNTSjA
Runner类代码
package helpers;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
//features= "src/test/resources/features/navigation",
@RunWith(Cucumber.class)
@CucumberOptions(
features = {"classpath:features"},
plugin = {"pretty", "html:target/cucumber-html-report"},
tags = {"@OnlyOneTime"},
// dryRun = true,
monochrome = true
)
public class RunCukesTest{
}
答案 0 :(得分:0)
我找出了你的问题,根据你的跑步者类,没有设置胶水路径。请设置胶水路径。glue={"stepDefinitions"}
package helpers;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
//features= "src/test/resources/features"@RunWith(Cucumber.class) @CucumberOptions(
features = {"classpath:features"}, glue={"stepDefinitions"},plugin = {"pretty", "html:target/cucumber-html-report"}, tags = {"@OnlyOneTime"}, // dryRun = true, monochrome = true )
public class RunCukesTest{ }
答案 1 :(得分:0)
将它作为黄瓜功能运行,效果很好,但如果我提供glue = {" stepDefinitions"}并尝试从跑步者运行它,则抛出NullPointerException,
这个问题是由于没有找到钩子引起的。但是,如果我将@Before和@After移动到SDLogin类,那么它运行良好。
答案 2 :(得分:0)
胶水代码应该具有钩子和步骤定义的路径
修改为glue={"helpers","stepDefinitions"}
而非。{
glue={"helpers","classpath/stepDefinitions", "classpath/stepDefinitions.LogIn","classpath/stepDefinitions.Publish"}
请参阅此链接Similar issue on github