← Back to team overview

launchpad-dev team mailing list archive

Re: wave a feature flag today!

 

On 18 August 2010 18:09, Robert Collins <robert.collins@xxxxxxxxxxxxx> wrote:
> Martin, what do you suggest developers do to write tests that check
> how something looks with a feature on/off ?

Good question!  I'm still kind of learning how to test things
tastefully in lp myself and building infrastructure for testing them,
but what I have done in test_flags.py is to do
store.add(model.FeatureFlag(...)) to set up the relevant rules, and
then just test it.  This will go into the database but we can rely on
the database changes just being aborted at the end of the test.

As a general principle the tests should be totally isolated from any
feature configuration: if they need a rule, they should set it
themselves.

I think we want to write a few different kinds of test:

1- most important; "assuming flag X is set for the current request, Y
should happen" - we want to set the flag; we don't care how the flag
gets to be set; we could have a mock feature controller that does not
need to touch the database.  We want to be able to do this either in
code or page tests.  Perhaps it should be a test fixture.

2- test whether a particular request is detected to be in a particular
scope or not

3- internal tests for how rules are evaluated, how the ui for editing
them works, etc...

-- 
Martin



Follow ups

References