【发布时间】:2020-05-08 22:02:15
【问题描述】:
我开始学习 Cucumber(行为驱动测试框架),并根据某些视频和一些阅读资料,我了解到 Cucumber 将自动为功能文件中定义的步骤定义生成骨架代码。但是,我没有看到任何正在执行的测试或正在生成的任何代码。我的项目设置如下
Project
----src/main/java/testrunner/MyTestRunner.java
----src/main/resources/feature/dailyroutine.feature
功能文件如下所示
Feature: Test Facebook smoke Scenario
Scenario: Test with valid credentails
Given: Open firefox and start application
When: when I enter with valid username and password
Then: I should be able to login into Facebook Homepage
TestRunner如下
package testrunner;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(features ={"src/main/resources/feature/dailyroutine.feature"},
dryRun=true,
strict=true,
monochrome=true)
public class MyTestRunner {
}
当我将 TestRunner 作为 JUnit 运行时,我得到了 0 场景 0 步 0m0.000s
我做错了什么
【问题讨论】:
-
你的黄瓜选项在你的路径中有空间?
-
另外,您使用的关键字错误。 GIVEN:用于传递参数,(您可以输入“browserName”、“UserName”、“Password”WHEN:事件触发 THEN:断言
-
我更改了 cucumberOptions。粘贴到stackoverflow时,额外的空间是一个错字。无论如何,我已经删除了额外的空间。你是说 Gherkin 关键字没有正确使用,因为没有生成骨架。
-
我认为我的问题在于 GIVEN、WHEN 和 THEN 之后的冒号,删除它们后它工作正常。
-
是的没错!,我也错过了哈哈,顺便看看我的回答,我可以建议另一种场景格式。
标签: cucumber