testing - Cucumber Feature 文件看不到 "step"文件

标签 testing cucumber

这只是我使用 Cucumber 的第二天。我已经创建了测试文件和步骤文件。 Cucumber 启动并运行,但它继续告诉我编写步骤文件。这些文件是否有命名约定,或者我是否需要以某种方式指向步骤文件?我正在尝试学习教程。

谢谢

cucumber :版本 3.1.0

Ruby 版本:2.4.1p111(2017-03-22 修订版 58053)[x86_64-darwin16]

rspec-核心 3.7.1

 test/features/step_definitions/test_step.rb


require 'watir'
require 'colorize'

browser = Watir::Browser.new


Given(/^I am on Guru99 Demo Page$/) do

  browser.goto "http://demo.guru99.com"

 end


 When (/^Enter blank details for login$/)do
   browser.text_field(:name,"emailid").set (" ")
   browser.button(:name,"btnLogin").click 
 end

 Then (/^Show error message$/)do
   puts 'Email is Required!'.red
   browser.close
 end

还有我的测试文件:

测试/特征/test.feature

Feature: guru99 Demopage Login
 In order to Login in Demopage we have to enter login details


 Scenario: Register On Guru99 Demopage without email

 Given  I am on the Guru99 homepage

 When enter blank details for Register

 Then error email shown

这是我运行 Cucumber 时控制台中的结果。

ZeroCalms-MacBook-Pro:features ZeroCalm$ cucumber test.feature

Feature: guru99 Demopage Login
 In order to Login in Demopage we have to enter login details

  Scenario: Register On Guru99 Demopage without email # test.feature:5
    Given I am on the Guru99 homepage                 # test.feature:7
    When enter blank details for Register             # test.feature:9
    Then error email shown                            # test.feature:11

1 scenario (1 undefined)
3 steps (3 undefined)
0m0.026s

You can implement step definitions for undefined steps with these 
snippets:

Given("I am on the Guru{int} homepage") do |int|
  pending # Write code here that turns the phrase above into concrete 
  actions
end

When("enter blank details for Register") do
  pending # Write code here that turns the phrase above into concrete 
  actions
end

Then("error email shown") do
  pending # Write code here that turns the phrase above into concrete 
  actions
end

最佳答案

您应该使步骤定义中的表达式与特征文件中的步骤“完全”匹配。

所以 I am on Guru99 Demo Page 在步骤定义上不同于I am on the Guru99 homepage

Enter blank details for login 相同,不同于 enter blank details for Register

Show error message 也一样,不同于error email shown

这就是您获得实现这些步骤定义的建议的原因:

You can implement step definitions for undefined steps with these 
snippets:

Given("I am on the Guru{int} homepage") do |int|
  pending # Write code here that turns the phrase above into concrete 
  actions
end

When("enter blank details for Register") do
  pending # Write code here that turns the phrase above into concrete 
  actions
end

Then("error email shown") do
  pending # Write code here that turns the phrase above into concrete 
  actions
end

因为 Cucumber 找不到。

关于testing - Cucumber Feature 文件看不到 "step"文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48996990/

相关文章:

RESTAssured 多部分内容类型

testing - Jenkins 如何让后期构建使用之前构建的工作区

api - Karate Api 测试 - 如何将数据从一个功能文件传递到另一个功能文件

java - 轴突测试 : Missing Context

asp.net - 负载测试和分析 ASP.NET Web 应用程序的当前最佳实践是什么?

ruby-on-rails-3.1 - 您不能同时使用 --strict 和 --wip (RuntimeError)

html - 如何在 capybara 中向键发送向下箭头

ruby-on-rails - Rails 控制台和 rake 测试 :units

ruby-on-rails - 将 webrat 的 contains(text) 匹配器与 haml 结合使用

java - Cucumber:不允许扩展定义步骤定义或 Hook 的类