Data-driven testing

Fredrik Lundh fredrik at pythonware.com
Wed Apr 23 15:21:35 EDT 2003


Aahz wrote:

> There were several times when I wrote what I thought were
> correct tests for the BCD module, and my code was right and
> my test was wrong.

here's the effbot "don't think if you don't have to" approach
to successful testing:

1. create a test script.
2. use 'doctest' to verify that your test script works as
   expected.  add functions with docstrings to the test
   script, and add code to the docstrings that exercises
   parts of your code.
3. add a few simple tests with expected results
4. write code
5. when all the simple tests pass, add more sophisticated
   tests, but don't add any expected output just yet.
6. run the test again, to see what results your code is producing.
   verify the results manually, in some suitable way.
   - for each result that turns out to be correct, copy the
      result into the test suite.
   - if you get a bogus result, go back to item 4.
7. if you feel that you need more tests, go to item 5.
8. if you need to add more features, go to item 3.
9. ????
X. profit!

</F>








More information about the Python-list mailing list