kingpong / perl-Test-Spec

rSpec-like test system for Perl
http://search.cpan.org/dist/Test-Spec/lib/Test/Spec.pm
30 stars 17 forks source link

Rework running of 'after all' to not rely on global destruction #33

Open perljedi opened 8 years ago

perljedi commented 8 years ago

Current implementation means that all the "after all" tear down action happen during global destruction. This means that the "after all" for a nested describe is not run before the examples in a subsequent nested describe. This adjusted implementation will "after all" blocks after the last test within their context, but before the examples of any subsequent contexts. This does come at a performance cost, as after ever test we need to check to see if the next test (if there is one) is in a sibling or parent context. However by my observation, this performance cost is negligible in the context or running unit tests.

It is not as graceful a solution as allowing global destruction to trigger the "after all" tasks, but it does result in execution of these blocks at what I'd consider to be the expected time during execution.

andyjones commented 8 years ago

Thanks, this is a nice improvement!

perljedi commented 8 years ago

Anything I more I can do on this one?