Hello, I am quite new to Ruby and Watir I started writing some test cases and I
wanted to try to tie them into a test suite but unfortunately the example shown
in http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/ doesn't work for me.
My test suite is very simple - just for trying out. It has to execute two test
cases - login and logout, but when I execute it I get the following errors:
C:\watir-v1_4\myTests>ruby mybox_suite.rb
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_re
quire': no such file to load -- unittests/setup (LoadError)
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `re
quire'
from ./mybox_login1.rb:15
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `re
quire'
from mybox_suite.rb:6
I'd like to get some explanation about how to write test cases, which can be
run separately and tied into a test suite. I have been reading for couple of
days articles and posts from blogs, forums, documentatin , etc., but I haven't
found a solution.
Here is the content of my test suite:
require 'test/unit/testsuite'
require 'mybox_login1'
require 'mybox_logout1'
class TS_MyTests
def self.suite
suite = Test::Unit::TestSuite.new
suite << TC_MYBOX_Login.suite
suite << TC_MYBOX_Logout.suite
return suite
end
end
And here is for example the login test:
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
require 'unittests/setup'
require 'test/unit'
require 'watir/WindowHelper'
require 'watir'
require "mysql"
class TC_MYBOX_Login < Test::Unit::TestCase
include Watir
# set variables
$host = '192.168.0.1' - this is a fake host I'm using another in the
true test
$user_login = 'test_demo'
def test_login()
# set variables
user_pass = '123';
test_site = 'http://'+ $host
# print some comments
puts "## Beginning of test: 'Mybox Login'"
puts " "
puts "Step 1: go to the test site: " + test_site
$ie.goto(test_site)
puts "Step 2: enter '"+$user_login+"' in login field"
$ie.text_field(:name, "login").set($user_login)
puts "Step 3: enter '"+user_pass+"' in password field"
$ie.text_field(:name, "password").set(user_pass)
sleep 1
puts "Step 4: click the 'Login' button"
$ie.button(:name, "login_button").click
puts "Expected Result: "
puts "Actual Result: Check that the 'Log Out' link appears on
the results page"
assert($ie.contains_text("Log Out"))
end
end
When I comment the "require unittests/setup". Then I get:
1) Error:
test_login(TC_MYBOX_Login):
NoMethodError: undefined method `goto' for nil:NilClass
./mybox_login1.rb:39:in `test_login'
2) Error:
test_logout(TC_MYBOX_Logout):
NoMethodError: undefined method `goto' for nil:NilClass
./mybox_logout1.rb:51:in `test_logout'
Thanx in advance :)
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=5078&messageID=14122#14122
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general