0
我正在使用Cucumber的Cucumber構建我的網站測試框架。我找到了一種使用鉤子在黃瓜的水豚司機之間切換的方法。我想在不測試JavaScript的情況下使用RackTest,因爲我相信RackTest更快,因爲它不會呈現頁面。現在我已經創建了3個相同的測試,可以跳轉到Google並檢查標題是否爲Google。每個測試使用不同的驅動程序。 Selenium和WebKit測試工作正常,但RackTest在「」上失敗,我應該看到標題「Google」「測試。我附上了我的功能和步驟的副本,並測試了這篇文章中的寶石。cucumber - RackTest無法正常測試Selenium和WebKit都成功了
特點:
Feature: Rack Test
In order to run test faster
As a tester
I want to use Rack Test to preform all non-javascript related test
Scenario: Visit a page and check title
When I go to "http://www.google.com"
Then I should see the title "Google"
@firefox
Scenario: Visit a page and check title in Firefox
When I go to "http://www.google.com"
Then I should see the title "Google"
@webkit
Scenario: Visit a page and check title in WebKit
When I go to "http://www.google.com"
Then I should see the title "Google"
步驟:
When /^I go to "(http:\/\/[^"]*)"$/ do |url|
visit url
end
Then /^I should see the title "([^"]*)"$/ do |title_cont|
page.should have_selector "title", text: title_cont
end
魚鉤:
Before('@firefox') do
Capybara.current_driver = :selenium
end
Before('@webkit') do
Capybara.current_driver = :webkit
end
After('@firefox, @webkit') do
Capybara.use_default_driver
end
的Gemfile:
group :test do
gem 'capybara'
gem 'capybara-webkit'
gem 'cucumber'
gem 'cucumber-rails'
gem 'database_cleaner'
gem 'factory_girl_rails'
gem "rack-test", require: "rack/test"
gem 'rspec'
gem 'selenium-webdriver'
end
好的,謝謝!很高興知道。 – Nick 2012-03-27 15:44:44