문제

I like the overall idea of Capybara, but i can't run it against the Java application for some reason.

Is that possible at all?

Thank you

도움이 되었습니까?

해결책

Yes, it is possible and we are doing it. Just use the selenium-webdriver gem with firefox or Chromium to remotely test the running application.

You can't test it from the Java test environment as you don't have the Rack infrastructure, but you can create a separate ruby testsuite and run rake when your java app is running on your development machine (or even autostart the application from the Rakefile)

This is how cucumber's env.rb looks like:

#
# 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

다른 팁

Capybara is tied to Ruby as far as I know. However, if you're interested in using Cucumber with Java then check out cuke4duke: http://wiki.github.com/aslakhellesoy/cuke4duke/

You can use a variety of languages for writing the step definitions and drive the browser with WebDriver.

Just stumbled on this one, and found that cuke4duke has been discontinued. However, the better news is that there's an official implementation of Cucumber for JVM available, as cucumber-jvm.

PS. At first I thought it would be JCucumber :P

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top