Any thoughts on what I can do/use to run cucumber scenarios in parallel on Windows? So far, I've tried (with the follow findings):
WatirGrid
Have to use Ruby threads to actually run in "parallel". This forces us to wrap the browser object in a thread, and therefore un-reachable once the thread block closes. (Can't pass Br开发者_运维问答owser object to cucumber environment)
Hydra:
Need SSH (and public-key) access to remote boxes (ie. No Windows)
Selenium Grid:
Super heavy and can't find clear Cucumber testing path
TestJour:
Requires Bonjour (which isn't available for Windows)
Re Watirgrid ...
I've since added an iterate method which can be passed a block of watir code to execute against remote browser objects. So the browser objects become reusable between steps. An updated detailed cucumber example is here:
https://github.com/90kts/watirgrid/blob/master/examples/cucumber/step_definitions/example_steps.rb
Your cuke steps end up looking like this:
Given /^navigate to the portal$/ do
@grid.iterate {|browser| browser.goto "http://gridinit.com/examples/logon.html" }
end
When /^they enter their credentials$/ do
@grid.iterate do |browser|
browser.text_field(:name => "email").set "tim@mahenterprize.com"
browser.text_field(:name => "password").set "mahsecretz"
browser.button(:type => "submit").click
end
end
Then /^they should see their account settings$/ do
@grid.iterate do |browser|
browser.text.should =~ /Maybe I should get a real Gridinit account/
end
end
If you have any questions feel free to drop me a line. We also have a commercial implementation of watirgrid on EC2 available for beta at http://gridinit.com/public/examples so stay tuned for more updates with different test frameworks!
FYI the control / iterate helpers are in the latest version of watirgrid v1.1.2
Alternatively to do it in parallel with different scenarios on each of the providers, I would just have a support/env.rb that looks something like this:
require 'watirgrid'
require 'rspec/expectations';
ENV["GRID"] = 'true'
ENV["controller_uri"] = "druby://10.0.1.3:11235"
if ENV["GRID"] then
params = {}
params[:controller_uri] = ENV["controller_uri"]
params[:browser] = 'chrome' # type of webdriver browser to spawn
grid ||= Watir::Grid.new(params)
grid.start(:initiate => true, :quantity => 1, :take_all => true)
else
@browser ||= Watir::Browser.new :chrome
end
Before do |scenario|
@browser = grid.providers.first
end
at_exit do
grid.iterate do |browser|
browser.close
end
grid.release_tuples
end
Note I'm using :take_all => true
to get exclusive access to a provider and releasing it back to the grid at_exit
... I would then call my scenarios from a separate test runner using the CLI, maybe wrapped in a bash or DOS script e.g.
cucumber features --name "Name of scenario 1"
cucumber features --name "Name of scenario 2"
cucumber features --name "Name of scenario 3"
...
etc
精彩评论