calling a testcase from another class

M

Mario Ruiz

Hi everybody,
I have a few classes containing a few tescase methods.
I would like to create a new class in order to run different tescases
methods of different classes:

file: testcases/myclass1.rb
class Myclass1 < Test::Unit::Testcase
def setup
end
def test01_example
end
def test02_example
end
def test03_example
end
def teardown
end
end

file: testcases/myclass2.rb
class Myclass2 < Test::Unit::Testcase
def setup
end
def test01_example
end
def test02_example
end
def teardown
end
end

file: testsuites/running.rb
class RunningTestCases < Test::Unit::Testcase
def setup
end
def test01_beep

require 'testcases/myclass1'
Myclass1.new().test03_example()
Myclass1.new().test01_example()

require 'testcases/myclass2'
Myclass2.new().test01_example()
end
def teardown
end
end


This is more or less what I'm trying to do, but it's not working.

Any idea?
 
M

Mario Ruiz

In the example I was inheriting from Test::Unit::Testcase but I'm not
doing that in the real example, I'm inheriting from a superclass that is
inheriting from Test::Unit::Testcase, but I think it doesn't matter.

So any ideas..... I'll really appreciate it.

Thank you.
 
T

Thomas Preymesser

Hi Mario,


Hi everybody,
I have a few classes containing a few tescase methods.
I would like to create a new class in order to run different tescases
methods of different classes:

file: testcases/myclass1.rb
class Myclass1 < Test::Unit::Testcase


it's class Myclass1 < Test::Unit::TestCase

file: testsuites/running.rb
class RunningTestCases < Test::Unit::Testcase
def setup
end
def test01_beep

require 'testcases/myclass1'
Myclass1.new().test03_example()
Myclass1.new().test01_example()


are you coming from Java-Programming?


you don't need all the stuff in your running.rb script.

Just create a running.rb file with this content:

require 'test/unit'
require 'myclass1'
require 'myclass2'

Calling this script all your tests will be executed.

For further examples you might read some tutorials for organizing test in
test-cases and test-suites.

-Thomas






--=20
Thomas Preymesser
(e-mail address removed)
(e-mail address removed)
B=FCro: 030 - 830 353 88
mobil: 0176 - 75 03 03 04
Privat: 030 - 49 78 37 06
http://thopre.wordpress.com/
http://www.thopre.com/
 
M

Mario Ruiz

Hi Thomas, I knew it.
What I was trying to do is to run not all the test cases in each file.
For example only test03_example() and test01_example() from MyClass1
and test01_example() from MyClass2
 
M

Mario Ruiz

Another solution could be using the 'include' sentence but the result is
the same, it doesn't work
 
T

Thomas Preymesser

Hi Mario,

Hi Thomas, I knew it.
What I was trying to do is to run not all the test cases in each file.
For example only test03_example() and test01_example() from MyClass1
and test01_example() from MyClass2


it will not help to create only specific test-objects in your script.
At the end of your script ALL test-definitions which where required are
executed - this is the way how test-unit works.

-Thomas

--=20
Thomas Preymesser
(e-mail address removed)
(e-mail address removed)
B=FCro: 030 - 830 353 88
mobil: 0176 - 75 03 03 04
Privat: 030 - 49 78 37 06
http://thopre.wordpress.com/
http://www.thopre.com/
 
M

Mario Ruiz

So it's impossible to execute only a few test cases methods of different
classes in a new class... isn't it?
 
M

Mario Ruiz

So it's impossible to execute only a few test cases methods of different
classes in a new class... isn't it?
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top