我正在尝试使用功能文件方案创建一个简单的测试用例:
Feature: Amazon Search Functionality
Scenario: Users can search for a specific item on Amazon
Given a user goes to Amazon
When they search for "pens"
Then amazon should return results for "pens"
用于步骤定义的Ruby代码是:
require 'watir-webdriver'
require 'cucumber'
Given(/^a user goes to Amazon$/) do
@browser= Selenium::WebDriver::Chrome::Profile.new
@browser.goto "http://www.amazon.com"
end
When(/^they search for "([^"]*)"$/) do |arg|
@browser.text_field(:id=> "twotabsearchtextbox").set "#{arg}"
@browser.send_keys: return
end
Then(/^amazon should return results for "([^"]*)"$/) do |arg|
@browser.div(:id=>"result_2").wait_untill_present
page_output = @browser.div(:id=> "resultsCol").text.include? "#{arg}"
assert (page_output=true)
@browser.close
end
我正在输出: 测试从凌晨3:49开始
C:\Ruby24-x64\bin\ruby.exe -EUTF-8 C:\Ruby24-x64\bin\cucumber C:/Users/rahulpathak01/Desktop/automatedtest/Features/Amazon_search.feature --format Teamcity::Cucumber::Formatter --expand --color -r features
WARNING: The formatter Teamcity::Cucumber::Formatter is using the deprecated formatter API which will be removed in v4.0 of Cucumber.
You can implement step definitions for undefined steps with these snippets:
Given("a user goes to Amazon") do
pending # Write code here that turns the phrase above into concrete actions
end
You can implement step definitions for undefined steps with these snippets:
When("they search for {string}") do |string|
pending # Write code here that turns the phrase above into concrete actions
end
You can implement step definitions for undefined steps with these snippets:
Then("amazon should return results for {string}") do |string|
pending # Write code here that turns the phrase above into concrete actions
end
1 scenario (1 undefined)
3 steps (3 undefined)
0m0.019s
我的文件夹结构正确,但rubymine无法找到步骤定义。
文件夹结构:
Features
Step Definitions
test.rb
testfeatures.feature