I just recently started coding in Ruby and began creating simple tests
combined with Selenium. Now however I want to create more advanced
tests.
The problem I have is that when I run my test for the search at my
website the test aborts when it hits an failure because of "Assert". I
have read about it and it's recommended to try to keep to 1 assert per
test to be able to find the fault more easily.
But when I try to divide my test in to smaller tests and create a Test
Suite/Case I don't know how to do it. I don't get how to do it. This is
my ugly code a the moment:
require "test/unit"
require "rubygems"
gem "selenium-client"
require "selenium/client"
class CompleteTest < Test::Unit::TestCase
def setup
@verification_errors = []
@selenium = Selenium::Client::Driver.new \
:host => "localhost",
:port => 4444,
:browser => "*chrome",
:url => "http://localhost/",
:timeout_in_second => 60
@selenium.start_new_browser_session
end
def teardown
@selenium.close_current_browser_session
assert_equal [], @verification_errors
end
def test_Search
@selenium.open "/"
assert @selenium.is_element_present("id=query")
@selenium.type("query", $query_miss)
@selenium.click("searchSubmit", :wait_for => :page)
assert @selenium.is_text_present("matchade inte några artiklar")
@selenium.type("query", $query_hit)
@selenium.click("searchSubmit", :wait_for => :page)
assert @selenium.is_element_present("id=topSearchPagination")
end
end
Here I would like to make test_Search into several smaller tests that
fails one by one if the asserts return failure. But how do I configure
such a test? And also I want to be able to create new testcases along
the way?
···
--
Posted via http://www.ruby-forum.com/.