Cucumber在执行时不生成代码

Cucumber在执行时不生成代码,cucumber,Cucumber,我开始学习Cucumber(行为驱动测试框架),基于某些视频和一些阅读,我了解Cucumber将自动生成步骤定义的框架代码,这些定义在功能文件中。然而,我没有看到任何测试正在执行或任何代码正在生成。我的项目设置如下 Project ----src/main/java/testrunner/MyTestRunner.java ----src/main/resources/feature/dailyroutine.feature package testrunner; import or

我开始学习Cucumber(行为驱动测试框架),基于某些视频和一些阅读,我了解Cucumber将自动生成步骤定义的框架代码,这些定义在功能文件中。然而,我没有看到任何测试正在执行或任何代码正在生成。我的项目设置如下

Project
  ----src/main/java/testrunner/MyTestRunner.java
  ----src/main/resources/feature/dailyroutine.feature
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 {

 }
功能文件如下所示

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如下所示

Project
  ----src/main/java/testrunner/MyTestRunner.java
  ----src/main/resources/feature/dailyroutine.feature
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 {

 }
当我以JUnit的身份运行TestRunner时 0场景 0步 0m0.000s


我犯了什么错误?

我想提出一个替代功能文件场景步骤

Feature Test Facebook smoke Scenario 
Scenario Success login with valid credentails
Given Using the browser "firefox"
And Username is "myUsername" with Password "myPassword"
When Submit login request
Then Successfully logged in to Facebook

问题可能是功能文件的措辞,即给定的额外冒号、时间和时间

我还对功能文件的编写方式进行了更改,以便更好地向读者介绍测试试图实现的目标,因为行为驱动开发(及其框架)关注的第一件事是开发团队和业务部门之间的沟通

Feature: Logging into Facebook...

  Scenario: with valid credentials
    Given I navigate to "Facebook"
    When I log in with my valid login details
    Then I should be able to see my newsfeed
可能还有其他问题,但就目前而言,冒号是我最关心的问题

编辑


我应该读一下评论部分,因为这是在回答这个问题的前两天解决的。

在功能文件中的关键字(
给定的
何时
,等等)后删除冒号(
)。

您的cucumber选项在路径中有空间吗?而且,您使用的关键字错误。给定:用于传递参数,(您可以输入“浏览器名”、“用户名”、“密码”当:触发事件,然后:断言我更改了cucumberOptions。粘贴到stackoverflow时,多余的空间是一个输入错误。无论如何,我已经删除了多余的空间。你是说没有正确使用小黄瓜关键字,因为没有生成骨架。我想我的问题是在给定后,何时,然后,在删除它们之后,我会使用冒号很好。是的,没错!我也错过了哈哈,顺便问一下,检查我的答案,我可以建议一种替代方案格式。在步骤def之后放冒号在dataTable之前是一种不好的做法吗?ex->然后通知应该显示如下:(dataTable)