Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Test Technique: Self-removing test data

by Mutant (Priest)
on Jul 18, 2007 at 08:44 UTC ( #627214=note: print w/replies, xml ) Need Help??


in reply to Test Technique: Self-removing test data

If you use Test::Class (which I highly recommend!), you can create 'setup' and 'teardown' methods (which run before and after each test), and 'startup' and 'shutdown' methods (which run before each test class).

You can even push these methods into a base class, and have related test classes inherit from this.

  • Comment on Re: Test Technique: Self-removing test data

Replies are listed 'Best First'.
Re^2: Test Technique: Self-removing test data
by markjugg (Curate) on Jul 18, 2007 at 13:30 UTC
    Test::Class looked interesting to me, too, and I tried in 2005, but I got a bizarre error and gave up.

    That issue has sense been resolved, and I'll consider giving it another shot. However, from looking at the source of Test::Class, it doesn't use the END {} block technique, even though it has a teardown() method, it is going to fail to clean up when the test script dies in the middle, which seems to be quite possible during development.

      Test::Class catches exceptions that happen in any of your test methods (including startup, shutdown, setup, and teardown methods) and registers the tests as failed.

      It's conceivable that you could die from outside of your test methods and that would prevent your cleanup from happening, but it would also probably mean that your setup didn't happen either.

      Test::Class is by no means perfect, but it deserves a little more credit than you give it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://627214]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2021-08-04 15:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My primary motivation for participating at PerlMonks is: (Choices in context)








    Results (41 votes). Check out past polls.

    Notices?