*Windows* 中的并行 Cucumber/Watir 场景

发布于 2024-11-05 08:16:53 字数 416 浏览 0 评论 0原文

关于我可以做什么/使用什么来在 Windows 上并行运行 Cucumber 场景有什么想法吗?到目前为止,我已经尝试过(有以下发现):

WatirGrid

必须使用 Ruby 线程实际“并行”运行。 这迫使我们将浏览器对象包装在一个线程中,因此 一旦线程块关闭就无法访问。 (无法传递浏览器对象 到黄瓜环境)

Hydra:

需要 SSH(和公钥)访问远程盒子(即没有 Windows)

Selenium Grid:

超级重,无法找到清晰的 Cucumber测试路径

TestJour:

需要 Bonjour(不适用于 Windows)

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 Browser 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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

对岸观火 2024-11-12 08:16:53

关于 Watirgrid ...

我添加了一个迭代方法,可以传递一个 watir 代码块来针对远程浏览器对象执行。因此浏览器对象在步骤之间可以重用。更新的详细黄瓜示例如下:

https://github .com/90kts/watirgrid/blob/master/examples/cucumber/step_definitions/example_steps.rb

你的 cuke 步骤最终看起来像这样:

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 "[email protected]"
    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

如果您有任何疑问,请随时给我留言。我们还在 EC2 上提供了 watirgrid 的商业实施,可用于测试版: http://gridinit.com/public/examples 请继续关注不同测试框架的更多更新!

仅供参考,控制/迭代帮助程序位于 watirgrid v1.1.2 的最新版本中。

另外,为了在每个提供程序上的不同场景中并行执行,我只需要一个 support/env.rb ,它看起来像这样的东西:

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

注意我正在使用 :take_all =>; true 获得对提供程序的独占访问权限并将其释放回网格 at_exit ...然后我将使用 CLI 从单独的测试运行程序调用我的场景,可能包含在 bash 中或 DOS 脚本,例如

cucumber features --name "Name of scenario 1"
cucumber features --name "Name of scenario 2"
cucumber features --name "Name of scenario 3"
...
etc

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 "[email protected]"
    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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文