0
votes

Am trying to run some watir test cases after upgrading to the current ruby and watir. They haven't been used for over a year (boring management prioritization story), but they were working fine when regularly run.

SCRIPT:
require 'watir'
require 'win32ole'
require 'yaml'

require 'test/unit'
require 'watir/assertions'
require 'watir/testcase'

ERROR:

C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require': cannot load such file -- watir/assertions (LoadError)

from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in require'
from C:/Users/joe.p/Desktop/ruby_auto_test/libs/require_gems.rb:16:in
'
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in require'
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
require' from smoke-test-1.rb:4:in `'

RUBY & GEMS INSTALLED:
C:>ruby -v ruby 1.9.3p0 (2011-10-30) [i386-mingw32]

C:>gem list

* LOCAL GEMS *

addressable (2.2.8)
bigdecimal (1.1.0)
builder (3.0.0)
childprocess (0.3.3)
commonwatir (3.0.0)
ffi (1.0.11, 1.0.9 x86-mingw32)
hoe (3.0.6)
io-console (0.3)
json (1.5.4)
libwebsocket (0.1.3)
minitest (2.5.1)
multi_json (1.3.6)
nokogiri (1.5.5 x86-mingw32)
rake (0.9.2.2)
rautomation (0.7.2)
rdoc (3.9.4)
rubygems-update (1.8.24)
rubyzip (0.9.9)
s4t-utils (1.0.4)
selenium-webdriver (2.24.0)
test-unit (2.5.1)
user-choices (1.1.6.1)
watir (3.0.0)
watir-classic (3.0.0)
watir-webdriver (0.6.1)
win32-api (1.4.8 x86-mingw32)
win32-process (0.6.5)
windows-api (0.4.1)
windows-pr (1.2.1)
xml-simple (1.1.1)

1

1 Answers

4
votes

Require Watir::TestCase

The Watir::TestCase has been moved to watir-classic, so you need to change

require 'test/unit'
require 'watir/assertions'
require 'watir/testcase' 

to

require 'watir-classic/testcase'

You do not need to require test/unit or watir/assertions since it is done automatically by watir/testcase.

Watir::TestCase on Ruby 1.9.3

I tried running the Watir::TestCase example (http://wtr.rubyforge.org/rdoc/1.6.5/classes/Watir/TestCase.html), however it fails due to missing method 'add_assertion' and 'add_failure'. These methods might be deprecated in the newer versions of Test/Unit (see http://apidock.com/ruby/Test/Unit/Assertions/add_assertion).

The quickest solution might be to install test/unit v1.2.3 (which was in Ruby 1.8.7). Then require that specific version (before requiring watir-classic/testcase):

gem "test-unit", "1.2.3"
require "test/unit"
require 'watir'
require 'watir-classic/testcase'

Alternatively, you can see if someone knows Test/Unit better than can address the bug. Though not sure how supported Watir::TestCase is.