[RFC] readonly branch and repository tests
Martin Pool
mbp at sourcefrog.net
Fri Jun 22 06:23:31 BST 2007
On 6/22/07, Robert Collins <robertc at robertcollins.net> wrote:
> On Fri, 2007-06-22 at 14:59 +1000, Martin Pool wrote:
> > On 6/22/07, Robert Collins <robertc at robertcollins.net> wrote:
> > > > In some ways it would be nice to have a different base class for these
> > > > tests, so that they can be stored in the same file as the other tests
> > > > for that logical area, but also clearly distinct.
> > >
> > > Thats another way of separating them, but it has the same failure mode -
> > > put the method on the wrong subclass and it won't run on readonly
> > > repositories.
> >
> > Well, you could hide make_repository and instead give people just apis
> > that are very clearly either for preparing the repository and for
> > examining it. I'm thinking about what we should do compared to
> > get_readonly_transport, which basically does a good job but some tests
> > seem to not quite use the right one.
>
> I'm not sure what you mean... In the general structure of a test there
> are three phases, which sometimes are clear and sometimes commingled
> (being commingled isn't bad). They are preparation, execution, and
> assertion. You prepare a fixture, you run the code under test, and you
> assert that it did the right thing. The right thing may be defined as
> 'made the right calls to other objects' or 'ended up with the right
> state' or any number of different things.
>
> We have a range of tests where the execution phase will mutate the
> object under test; thats incompatible with objects that cannot be
> mutated *by design* - its not a 'skipped test' or 'missing resource' -
> its 'something that should not be tested'.
That's a very good way to think about the general structure.
What I meant was: for readonly repositories we have to be more clear
about the distinction between preparation (which normally involves
mutation) and execution. Tests where execution is also preparation
for a later part of the test can get into trouble in two ways: either
they won't be run on readonly repositories (or it will be hard to make
them run), or they won't exercise the readonly code and so don't test
what they are meant to test. These tests are sometimes accidentally
mutating the repository, rather than essentially testing mutation
operations.
--
Martin
More information about the bazaar
mailing list