Does anyone know of a way of performing one-time setup and teardown per Test::Unit::TestCase?
I have an integration test with an external component where, unfortunately, mocking out a server response is not feasible. So I need to mount a servlet to interact with my test. It would be pointless and slow to do this once for every test method. I know other unit testing frameworks define such callbacks. Does Test::Unit? If not, is there a clever way of getting around it?
I am using Rails's 'test/helper', so I'm not instantiating my own test harness. Obviously, I can setup any needed resources in the class scope of the unit test itself, BUT that still doesn't give me a callback for teardown.
Any ideas?
Thanks for your help.
-- Ara Vartanian
···
____________________________________________________________________________________
Yahoo! Music Unlimited
Access over 1 million songs. http://music.yahoo.com/unlimited
Does anyone know of a way of performing one-time setup and teardown per Test::Unit::TestCase?
I have an integration test with an external component where, unfortunately, mocking out a server response is not feasible. So I need to mount a servlet to interact with my test. It would be pointless and slow to do this once for every test method. I know other unit testing frameworks define such callbacks. Does Test::Unit? If not, is there a clever way of getting around it?
I am using Rails's 'test/helper', so I'm not instantiating my own test harness. Obviously, I can setup any needed resources in the class scope of the unit test itself, BUT that still doesn't give me a callback for teardown.
Any ideas?
Thanks for your help.
-- Ara Vartanian
Déjà vu ???
As I pointed out in the previous thread I do my setup in some constant
accessible way, e.g. in a module or class or on script level.
Let us assume that I have a testobject that supports setup and teardown
...
MyTestObj = Testobject.new
MyTestObj.setup
class Tester < test::unit::Testcase
etc
for teardown you have to experiment with at_exit but I hope, please
test it though
that
at_exit do
MyTestObj.teardown
end
is *not* executed before the execution of the Testsuit by the
testrunner, not sure alas.
You can still write a pseudo testcase for the teardown but I agree
that this is a pain.
HTH
Robert
···
On 2/27/07, Ara Vartanian <ara_vartanian@yahoo.com> wrote:
____________________________________________________________________________________
Yahoo! Music Unlimited
Access over 1 million songs. http://music.yahoo.com/unlimited
--
We have not succeeded in answering all of our questions.
In fact, in some ways, we are more confused than ever.
But we feel we are confused on a higher level and about more important things.
-Anonymous
Does anyone know of a way of performing one-time setup and teardown per Test::Unit::TestCase?
Do it at class level and store it in a class variable or constant.
I have an integration test with an external component where, unfortunately, mocking out a server response is not feasible. So I need to mount a servlet to interact with my test. It would be pointless and slow to do this once for every test method. I know other unit testing frameworks define such callbacks. Does Test::Unit? If not, is there a clever way of getting around it?
I don't believe you. I've tested complex interactions with a stub'd Net::HTTP. See rc_rest/uri_stub.rb and rc_rest/net_http_stub.rb.
I am using Rails's 'test/helper', so I'm not instantiating my own test harness. Obviously, I can setup any needed resources in the class scope of the unit test itself, BUT that still doesn't give me a callback for teardown.
Have you tried BEGIN {} and END {}? But perhaps there's something more graceful.
-Mat
···
On Feb 27, 2007, at 3:25 PM, Ara Vartanian wrote:
Does anyone know of a way of performing one-time setup and teardown per Test::Unit::TestCase?
I have an integration test with an external component where, unfortunately, mocking out a server response is not feasible. So I need to mount a servlet to interact with my test. It would be pointless and slow to do this once for every test method. I know other unit testing frameworks define such callbacks. Does Test::Unit? If not, is there a clever way of getting around it?
I am using Rails's 'test/helper', so I'm not instantiating my own test harness. Obviously, I can setup any needed resources in the class scope of the unit test itself, BUT that still doesn't give me a callback for teardown.