[rfc] add a TestFactory class or concept
aaron at aaronbentley.com
Thu Aug 6 21:25:35 BST 2009
-----BEGIN PGP SIGNED MESSAGE-----
Martin Pool wrote:
> Lots of tests are run on some specific values; for instance they make
> a branch and then do some operations on it.
We need specific values in order to make assertions about them, and to
provide legibility. Could you please explain what about this is bad?
> 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
Cleaner or not, I find bzr's approach much easier to use.
> (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.
I don't understand. There are plenty of examples where we create Person
objects with specific email addresses and names. Look at this method
self, email=None, name=None, password=None,
displayname=None, time_zone=None, latitude=None, longitude=None):
These are all the things we've felt a need to specify in one test case
It's true that we don't have to specify anything at all to makePerson.
If you were arguing that we should improve our existing helpers, I could
understand that, but I don't see how it relates to a TestFactory concept.
> 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.
I find that concrete examples are easier to understand when you get test
failures. For example, if you get an exception containing a branch
path, and the branch path includes the test case variable name, it's
much easier to see what's going on. I've never used BranchBuilder, for
example, and hardly ever used MemoryTree.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
More information about the bazaar