# New to Ruby testing

**URL:** <https://rubytalk.org/t/new-to-ruby-testing/63383>\
**Category:** ruby-talk\
**Created:** [19 August 2011 08:57 UTC](https://rubytalk.org/t/new-to-ruby-testing/63383 "2011-08-19T08:57:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonathan\_Svard](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@Jonathan\_Svard](https://rubytalk.org/u/Jonathan_Svard)\
**Post date:** [19 August 2011 08:57 UTC](https://rubytalk.org/t/new-to-ruby-testing/63383/1 "2011-08-19T08:57:08Z")

</div>

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  
&nbsp;&nbsp;def setup  
&nbsp;&nbsp;&nbsp;&nbsp;@verification\_errors = []  
&nbsp;&nbsp;&nbsp;&nbsp;@selenium = Selenium::Client::Driver.new \  
&nbsp;&nbsp;:host =\> "localhost",  
&nbsp;&nbsp;:port =\> 4444,  
&nbsp;&nbsp;:browser =\> "\*chrome",  
&nbsp;&nbsp;:url =\> "[http://localhost/](http://localhost/)",  
&nbsp;&nbsp;:timeout\_in\_second =\> 60  
&nbsp;&nbsp;@selenium.start\_new\_browser\_session  
&nbsp;&nbsp;end

&nbsp;&nbsp;def teardown  
&nbsp;&nbsp;&nbsp;&nbsp;@selenium.close\_current\_browser\_session  
&nbsp;&nbsp;&nbsp;&nbsp;assert\_equal [], @verification\_errors  
&nbsp;&nbsp;end

&nbsp;&nbsp;def test\_Search  
&nbsp;&nbsp;&nbsp;&nbsp;@selenium.open "/"  
&nbsp;&nbsp;&nbsp;&nbsp;assert @selenium.is\_element\_present("id=query")  
&nbsp;&nbsp;&nbsp;&nbsp;@selenium.type("query", $query\_miss)  
&nbsp;&nbsp;&nbsp;&nbsp;@selenium.click("searchSubmit", :wait\_for =\> :page)  
&nbsp;&nbsp;&nbsp;&nbsp;assert @selenium.is\_text\_present("matchade inte några artiklar")  
&nbsp;&nbsp;&nbsp;&nbsp;@selenium.type("query", $query\_hit)  
&nbsp;&nbsp;&nbsp;&nbsp;@selenium.click("searchSubmit", :wait\_for =\> :page)  
&nbsp;&nbsp;&nbsp;&nbsp;assert @selenium.is\_element\_present("id=topSearchPagination")  
&nbsp;&nbsp;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/](http://www.ruby-forum.com/).
