[rfc] testtools test fixtures

Robert Collins robertc at robertcollins.net
Thu Jun 10 06:24:55 BST 2010


Thanks for this; I missed the attachment before, thus my tardy reply.

A few thoughts... in no particular order.

Many domain objects do need cleaning up - OS locks being among the
most common things (for working trees, which nearly all our tests
use).

I think its undesirable for fixtures to know about the test case: test
cases provide nothing they would need (in an ideal world).

Some of your open questions seem to me to be 'do what works, there
isn't a golden answer' - e.g. tests that damage a branch would want a
fixture that fixes/deletes unconditionally. Or something. And I think
some fixtures will be factories, others will be useful things
themselves, and still others will just help arrange things
conveniently.

"
So if that's not acceptable we do need a way for fixtures that are created
arbitarily far inside a dependency chain to know which TestCase (or other
ObjectWithCleanups) should be destroying them."
^ That didn't make sense to me.

I think a trivial decorator could decorate interesting domain objects
that don't need teardown, that are cheap to make, with a
setUp/tearDown pair: its easier to add that, than to make things that
need explicit removal safe with implicit gc.

I think moving all non-infrastructure state from the tests will make
things nicer overall, even though it is a tad more typing : its simply
on the wrong object.

-Rob



More information about the bazaar mailing list