On Tuesday 23.11.2010 15:02:27 Josep M. Fontana wrote: > Does anybody know of any good reference on testing? How do you develop > tests for functions? I haven't found much information on this in the > Python books I own.
The basic idea is to call your function with known inputs, and test if it has the desired output. For practical application you use a test framework, and write the tests in the format that the framework recognizes. The framework will then run the tests, print eventual error messages, and a summary of the test run. In "Test Driven Development" you write the tests first and the program code second. This is IMHO very useful as you do at least some design (API design). For more information google for: "Python test driven development" Here are some websites that seem promising: http://en.wikipedia.org/wiki/Test-driven_development http://www.slideshare.net/Siddhi/test-driven-development-with-python I use the "py.test" framework but there are also "nose", the built in "unittest" and the built in "Doctest". (Pydev/Eclipse can somehow collaborate with "unittest" I think.) http://codespeak.net/py/dist/test/ http://somethingaboutorange.com/mrl/projects/nose/0.11.2/index.html http://docs.python.org/library/unittest.html http://docs.python.org/library/doctest.html Eike. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor