首页 文章

我在Eclipse中使用Java Build 了一个简单的自动化框架,但是无法通过Junit运行Cucumber测试

提问于
浏览
0

我是Cucumber和Java的新手(来自Specflow / C#背景) . 我试图 Build 我在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();

});

但是,向我建议的语法不正确 . 任何想法为什么语法错误以及为什么我的测试不运行?

1 回答

  • 0

    建议的语法(片段)适用于java8 . 如果要使用常规java语法,请使用cucumber-java依赖项而不是cucumber-java8依赖项 .

    您收到步骤未定义的消息的原因是因为Cucumber无法找到您的胶水 . 确保在“glue =”的黄瓜选项中提供步骤定义的正确位置 .

相关问题