我对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脚本会返回与之前完全相同的结果。我将所有内容都放在名为“features”的文件夹中,而.rb文件位于名为step_definitions的子文件夹中。我究竟做错了什么?我似乎无法在网上找到答案,所以任何帮助都将非常感谢!
答案 0 :(得分:0)
由于您的要素文件和步骤定义位于features
文件夹中,请尝试使用--require features
选项运行黄瓜。