Thomas Klausner wrote:
> Is there any module on CPAN (or some other accepted technique) to 
> maintain some kind of state between tests?
> 
> I know that this will kill parallel testing, but I'm trying to test a 
> rather long process involving several files and several steps, factored 
> into several distinct test scripts, and I don't want to write lots of 
> setup code before each step of the test.
> 
> Basically, I'd love to use the CLEANUP feature of File::Temp, but 
> instead of triggering the CLEANUP after one test script exists, I'd like 
> to trigger it manually. Of course I know that I can just write out the 
> path somewhere and remove the testdir when I'm done. But I'm wondering 
> if this is already built in one test module or the other (similar to 
> what Module::Build offers with config_data)

Before I came to my senses, MakeMaker used to have a 00setup.t and a
zz_teardown.t to create and delete dummy modules for testing purposes.  Its
simple and MakeMaker guarantees the order of the tests.

Problem was, it didn't work.  If one test failed and dirtied the test modules
the rest would fail in new and interesting ways making it difficult to trust
test results after the first failure.  If I wanted to run a single test I had
to remember to manually run 00setup.t, then the test, then zz_teardown.t.
Often I forgot.  If a user ran "make test", killed it in the middle and then
ran it again they'd get bogus results.

For that reason I believe the idea is fundamentally flawed and a pain in the 
ass.

Instead, I put the MakeMaker test module creation code into little test
modules in t/lib.  Now each test can just load the appropriate setup module to
create the necessary test files, and throw it out at the end.

So I'd suggest an approach like that.  Keep each test file as a stand alone
unit.  Shove common setup/teardown code into a module.


-- 
124. Two drink limit does not mean first and last.
    -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army
           http://skippyslist.com/list/

Reply via email to