Test cases dependencies?

Hi rubyists :wink:

Is it possible to create dependencies between ``test_’’ methods, in a
Test::Unit::TestCase object?

For instance, imagine the following:

Tests the ``foo’’ library.

require ‘test/unit’
class TC_foo < Test::Unit::TestCase
def test_init
# Test if the foo library can be initialized.
end
def test_bar
# Test the ``bar’’ method of the foo library.
# This test requires that the library was
# correctly initialized before.
end
end

If I run this sample, Test::Unit will firstly execute test_bar'', and secondlytest_init’’, because bar'' cames beforeinit’’ in the
alphabetical order.

I would like that test_bar'' depends oftest_init’’.

Any ideas?

···


Laurent

Generally, this is considered a bad thing, since tests are supposed to be atomic
and independent.

That said, there are ways around it with having your test methods call other,
non-test methods in whatever order you need.

···

-----Original Message-----
From: Laurent Sansonetti [mailto:laurent@datarescue.be]
Sent: Tuesday, May 20, 2003 4:00 AM
To: ruby-talk ML
Subject: Test cases dependencies?

Hi rubyists :wink:

Is it possible to create dependencies between ``test_‘’ methods, in a
Test::Unit::TestCase object?

For instance, imagine the following:

Tests the ``foo’’ library.

require ‘test/unit’
class TC_foo < Test::Unit::TestCase
def test_init
# Test if the foo library can be initialized.
end
def test_bar
# Test the ``bar’’ method of the foo library.
# This test requires that the library was
# correctly initialized before.
end
end

If I run this sample, Test::Unit will firstly execute test_bar'', and secondly test_init’‘, because bar'' cames before init’’ in the
alphabetical order.

I would like that test_bar'' depends of test_init’'.

Any ideas?


Laurent

You can find huge discussion waves on the subject in ruby-talk archives
(www.ruby-talk.org), one of them quite recently.

Gennady.

···

----- Original Message -----
From: “Laurent Sansonetti” laurent@datarescue.be
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Tuesday, May 20, 2003 1:00 AM
Subject: Test cases dependencies?

Hi rubyists :wink:

Is it possible to create dependencies between ``test_‘’ methods, in a
Test::Unit::TestCase object?

For instance, imagine the following:

Tests the ``foo’’ library.

require ‘test/unit’
class TC_foo < Test::Unit::TestCase
def test_init
# Test if the foo library can be initialized.
end
def test_bar
# Test the ``bar’’ method of the foo library.
# This test requires that the library was
# correctly initialized before.
end
end

If I run this sample, Test::Unit will firstly execute test_bar'', and secondly test_init’‘, because bar'' cames before init’’ in the
alphabetical order.

I would like that test_bar'' depends of test_init’'.

Any ideas?


Laurent