Loop unit test cases?

Hi,

Is there any way to loop TEST::UNIT test cases to accommodate
different data values?

class Test_Class < Test::Unit::TestCase

def test_1

end

def test_2

end

end

Thanks

Aidy

On 7/15/07, aidy [email protected] wrote:

end

def test_2

end

end

Can you explain a bit more?
normally people use:

class FoobarTestClass < Test::Unit::TestCase
def test_for_bar
<>.each do
#your assertions here
end
end


Let them talk of their oriental summer climes of everlasting
conservatories; give me the privilege of making my own summer with my
own coals.

http://blog.gnufied.org

On 14 Jul, 20:33, hemant [email protected] wrote:

Can you explain a bit more?

Hi,

I am still thinking about this, but I hope you get the idea

class TC < Test::Unit::TestCase
@@test = Test_Data.new

def setup
@browser = Browser.new
@browser.goto(test.data[:url])
login = Login.new(@@test.data[:username], @@test.data[:password])
login.sign_in.click
end

def teardown
application.log_out.click
@browser.close
end

def test_case_1

main_page.enter_field(@@test.data[:text])

end

end

class Test_Data
attr_accessor :data
def initialize

  username = ['user', 'invalid_name']
  password = ['pswd', 'invalid_password']
  text = ['something', 'else']

  @data= {
    :url => 'http://whatever',
    :username => username[@@i],
    :password => password[@@i]
    :text => text[@@i]
    }

   @@i += 1 unless username.length #need to work this out
end

end

Ideally I want to run the class TC until an array length is reached in
the Test_Data class.

Aidy