loop unit test cases?

A

aidy

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
 
H

hemant

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

Can you explain a bit more?
normally people use:

class FoobarTestClass < Test::Unit::TestCase
def test_for_bar
<<some collection object>>.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
 
A

aidy.lewis

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top