[rfc] add a TestFactory class or concept
mbp at canonical.com
Thu Aug 6 09:12:26 BST 2009
Lots of tests are run on some specific values; for instance they make
a branch and then do some operations on it.
I was talking to jml the other day and he said that Launchpad have a
cleaner separation of all of this setup into a TestFactory class
(iirc) - if you want a Person to test, you would always get that from
the factory rather than putting arbitrary example data into the class.
There are some tools such as BranchBuilder to do this. There are also
some utilities on TestCase and similar to provide dependencies, and to
integrate with test parameterization - for example
TestCase.get_transport() and the implicitly provided working
directory. On the other hand a lot of tests hardcode some test data.
So it's not black and white but I am wondering if we should push a bit
more towards separating this out from tests.
Some specific benefits I'd hope for:
* tests that need to run on "a branch that supports stacking"
wouldn't be hardcoded to one particular format
* we could run all the tests on, say, very large trees, or trees with
unicode names, and see if that reveals any gaps in coverage
* tests may be smaller or simpler to write
* we might get less use of bad or slow interfaces in tests
More information about the bazaar