是的,这是可能的,我们正在这样做.只需使用带有firefox或Chromium的selenium-webdriver gem来远程测试正在运行的应用程序.
您无法从Java测试环境中测试它,因为您没有Rack基础架构,但是当您的Java应用程序在您的开发机器上运行时,您可以创建单独的ruby测试套件并运行rake(或者甚至可以自动启动应用程序Rake文件)
这就是黄瓜的env.rb的样子:
#
# features/support/env.rb
#
$: << File.join(File.dirname(__FILE__), "..", "..", "lib")
browser = :chrome #:htmlunit #:chrome #:firefox
host = ENV['TESTHOST'] || 'http://localhost:8080'
# may be non url was given
if not host.include?("//")
host = "https://#{host}"
end
ENV['LANG'] = "en_US.UTF-8"
require 'rubygems'
require 'capybara'
require 'capybara/cucumber'
require 'selenium-webdriver'
require 'culerity' if browser == :htmlunit
case browser
when :htmlunit
Capybara.default_driver = :culerity
Capybara.use_default_driver
else
Capybara.default_driver = :selenium
Capybara.app_host = host
end
Capybara.run_server = false
if Capybara.default_driver == :selenium
Capybara::Driver::Selenium.browser = browser
driver = Selenium::WebDriver.for browser
end