黄瓜在执行时未生成代码

时间:2018-08-08 03:48:29

标签: cucumber

我开始学习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 {

 }

当我以JUnit运行TestRunner时, 0场景 0步 0m0.000s

我在做什么错

3 个答案:

答案 0 :(得分:0)

我想提出一个替代功能文件方案的步骤

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

答案 1 :(得分:0)

问题可能出在特征文件的措辞上,即给定,何时和随后的多余冒号。

我还对功能文件的编写方式进行了更改,以更好地告知读者该测试试图实现的目标-这是行为驱动开发(及其行为框架)的第一要务。重点是开发团队与企业之间的沟通。

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

可能还有其他问题,但暂时来说,冒号是我一直面临的问题

修改

我应该阅读评论部分,因为此问题在此答案的前两天就已解决

答案 2 :(得分:0)

删除功能文件中关键字(:Given等之后的冒号(When)。

相关问题