Calling a testcase from another class

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?

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.

Hi Mario,

On 06/02/2008, Mario R. [email protected] wrote:

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


Thomas P.
[email protected]
[email protected]
Büro: 030 - 830 353 88
mobil: 0176 - 75 03 03 04
Privat: 030 - 49 78 37 06


http://www.thopre.com/

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

Hi Mario,

On 07/02/2008, Mario R. [email protected] wrote:

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


Thomas P.
[email protected]
[email protected]
Büro: 030 - 830 353 88
mobil: 0176 - 75 03 03 04
Privat: 030 - 49 78 37 06


http://www.thopre.com/

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

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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs