我是Cucumber和Java的新手(来自Specflow / C#背景)。我正在尝试在eclipse中设置我的第一个项目并认为一切都设置正确(我可以从特征文件中访问我的步骤定义文件(使用F3 - 转到定义))。
我已经设置了一个testrunner文件,如下所示:
package cucumberTest;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(
features = "Feature"
,tags = "@LoginTests"
,glue={"src/stepDefinition"}
,dryRun = true
,monochrome = true
)
public class TestRunner {
}
我的问题是,当我通过Eclipse IDE运行Junit(v4.11)时,测试没有运行,我被告知方案和步骤未定义,并给出了解决问题的建议:
2 Scenarios (2 undefined)
6 Steps (6 undefined)
0m0.105s
You can implement missing steps with the snippets below:
Given("^User is on Home Page$", () -> {
//Write code here that turns the phrase above into concrete actions
throw new PendingException();
});
但是,向我建议的语法不正确。任何想法为什么语法错误以及为什么我的测试不运行?
建议的语法(片段)适用于java8。如果要使用常规java语法,请使用cucumber-java依赖项而不是cucumber-java8依赖项。
您收到步骤未定义的消息的原因是因为Cucumber无法找到您的胶水。确保在“glue =”的黄瓜选项中提供步骤定义的正确位置。