On Thu, Jun 24, 2004 at 07:09:40AM +0100, Piers Cawley wrote:
> The xUnit style framework does a much better job of enforcing test
> isolation than Test::More does

I see this more as a limitation than a feature.  It seems to mean that

- You need to use the same setup/teardown for all your tests.

- You're restricted to one test == one method, so you can't paramatrize
  your tests by data (eg, second example below).

- You don't have much control (correct me if I'm wrong) about the order
  of tests, or the relationship between tests, eg you can't say "if this
  test fails, skip these others".  This is straightforward in
  Test::More's simple procedural style.

If I need isolation, why can't I just ask for it directly?

    with_test_setup {
        run_tests();
    }

and even

    foreach (@my_test_data) {
        with_test_setup {
            run_tests($_);
        }
    }

> (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). 

This is the one point of actual difference, but I think we can take care
of it.  For starters,

    SKIP: {
        ok(something) || skip
        is(this, that) || skip;
    }

Even better would be to put Test::Builder in "skip" mode, where it skips
automatically whenever a test fails:

    skip_mode {
        ok(something);
        is(this, that);
    }

This can't play nice with test counts, but that's a brain-dead idea
anyway.

Every time I hear about xUnit, I figure there must be something other
than "setup and teardown" in its favor.  If that's all there is, I'm not
sold.

Andrew

Reply via email to