On 24 Jun 2004, at 07:09, Piers Cawley wrote:
[snip]
The xUnit style framework does a much better job of enforcing test
isolation than Test::More does (but you have to remember that what
Test::More thinks of as a test, xUnit thinks of as an assertion to be
used *in* a test).

To be fair to Test::More and friends xUnit doesn't /enforce/ test isolation any more than Test::More prevents it. Writing isolated tests with Test::More is trivial, just do something like:


sub make_fixture {
        return ( Cash->new(10), Cash->new(20) );
};

isa_ok( $_, 'Cash' ) foreach make_fixture();

{
  my ($ten, $twenty) = make_fixture();
  is_deeply $ten + $twenty, Cash->new(30);
};

... etc ...

I had a mild rant about this on the TDD list a few months back. You can write isolated tests in a procedural style quite easily. You can also easily write tightly-coupled tests in an xUnit style. It's all reliant on developer discipline. xUnit provides some infrastructure that helps, but it doesn't enforce it. Developers do that.

(Apologies for rant. Consider it a symptom of the number of ghastly xUnit test classes that I've seen with 100 line test methods and no setup methods.)

Where xUnit wins for me are in the normal places where OO is useful (abstraction, reuse, revealing intention, etc.). Where xUnit loses are the times when you don't need it all the extra infrastructure and it just becomes overhead that gets in the way of understanding the test suite.

Where the Perl testing framework wins for me:
- it gives me the flexibility to do both procedural and xUnit styles as I see fit
- it also provides SKIP and TODO tests, which I've not come across elsewhere. TODO test in particular I find useful for tracking technical debt
- Test::Harness has a nice ASCII protocol that I can use to feed non-Perl stuff into the testing framework


Anyway.... enough rambling ;-)

Adrian



Reply via email to