我的 Cucumber 脚本似乎没有选择我的 Ruby 脚本
My Cucumber script doesn't seem to be picking up my Ruby script
我是 Cucumber 和 Ruby 的新手,所以如果我遗漏的内容看起来很简单,请原谅我。我可以 运行 我的 Cucumber 脚本,它给了我以下结果:
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 Guru 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.040s
You can implement step definitions for undefined steps with these snippets:
Given(/^I am on the Guru homepage$/) do
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
这是意料之中的。但是,当我添加包含以下内容的 .rb 文件时:
require 'watir-webdriver'
require 'colorize'
browser = Watir::Browser.new
Given(/^I am on the Guru homepage$/) do
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 脚本 returns 与之前的结果完全相同。我将所有内容都放在名为 "features" 的文件夹中,.rb 文件位于名为 step_definitions 的子文件夹中。我究竟做错了什么?我似乎无法在网上找到答案,因此非常感谢任何帮助!
由于您的功能文件和步骤定义位于 features
文件夹中,请尝试使用 --require features
选项 运行 黄瓜。
我是 Cucumber 和 Ruby 的新手,所以如果我遗漏的内容看起来很简单,请原谅我。我可以 运行 我的 Cucumber 脚本,它给了我以下结果:
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 Guru 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.040s
You can implement step definitions for undefined steps with these snippets:
Given(/^I am on the Guru homepage$/) do
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
这是意料之中的。但是,当我添加包含以下内容的 .rb 文件时:
require 'watir-webdriver'
require 'colorize'
browser = Watir::Browser.new
Given(/^I am on the Guru homepage$/) do
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 脚本 returns 与之前的结果完全相同。我将所有内容都放在名为 "features" 的文件夹中,.rb 文件位于名为 step_definitions 的子文件夹中。我究竟做错了什么?我似乎无法在网上找到答案,因此非常感谢任何帮助!
由于您的功能文件和步骤定义位于 features
文件夹中,请尝试使用 --require features
选项 运行 黄瓜。