~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to doc/developers/testing.txt

  • Committer: Martin Pool
  • Date: 2010-10-11 07:08:31 UTC
  • mto: This revision was merged to the branch mainline in revision 5483.
  • Revision ID: mbp@sourcefrog.net-20101011070831-gg3wuhqzyxnzh9q1
Unify varations with scenario protocol

Show diffs side-by-side

added added

removed removed

Lines of Context:
826
826
values to which the test should be applied.  The test suite should then
827
827
also provide a list of scenarios in which to run the tests.
828
828
 
829
 
Typically ``multiply_tests_from_modules`` should be called from the test
830
 
module's ``load_tests`` function.
 
829
A single *scenario* is defined by a `(name, parameter_dict)` tuple.  The
 
830
short string name is combined with the name of the test method to form the
 
831
test instance name.  The parameter dict is merged into the instance's
 
832
attributes.
831
833
 
832
834
A higher-level interface for multiplying tests is *test variations*.  A
833
835
test class can declare a list of `TestVariation` objects, and the tests
837
839
 
838
840
    variations = [VaryByRepositoryFormat(), VaryByTreeFormat()]
839
841
 
840
 
the `TestVariation` must just provide a `scenarios` method that yields
841
 
`(variation_name, attr_dict)` pairs.  It may do this by looking in a
842
 
registry or at other dynamic information, so that plugins can cause new
843
 
scenarios to run.  Variations may of course take constructor paramaters to
844
 
change their behaviour.
845
 
 
846
 
If you use `variations`, adding this line to your test module will make
847
 
all classes automatically expand out.  You must have either this or a
848
 
manual `load_test`::
849
 
 
850
 
    from bzrlib.tests.variations import (
851
 
        load_tests_from_their_variations,
852
 
        )
853
 
 
854
 
    load_tests = load_tests_from_their_variations
855
 
 
856
 
Put the `load_tests` declaration or assignment immediately after the
857
 
import statements, so people can see the effect it will have on the rest
858
 
of the file.
 
842
you should then provide a `load_tests` method that will expand the tests.
 
843
A simple way to do this is just::
 
844
 
 
845
  load_tests = load_tests_from_scenarios
 
846
 
 
847
The `load_tests` declaration or definition should be near the top of the
 
848
file so its effect can be seen.
 
849
 
 
850
This is similar to the interface provided by `testscenarios`_ but we don't
 
851
currently use that implementation.
 
852
 
 
853
.. _testscenarios: http://launchpad.net/testscenarios
859
854
 
860
855
 
861
856
Test support