PyModel: Model-based testing in Python

Jonathan Jacky


PyModel is an open-source model-based testing framework in Python.

In unit testing, the programmer codes the test cases, and also codes assertions that check whether each test case passed. In model-based testing, the programmer codes a "model" that generates as many test cases as desired and also acts as the oracle that checks the cases.

Model-based testing is recommended where so many test cases are needed that it is not feasible to code them all by hand. This need arises when testing behaviors that exhibit history-dependence and nondeterminism, so that many variations (data values, interleavings, etc.) should be tested for each scenario (or use case). Examples include communication protocols, web applications, control systems, and user interfaces.

PyModel supports on-the-fly testing, which can generate indefinitely long nonrepeating tests as the test run executes. PyModel can focus test cases on scenarios of interest by composition, a versatile technique that combines models by synchronizing shared actions and interleaving unshared actions. PyModel can guide test coverage according to programmable strategies coded by the programmer.

PyModel provides three programs:

Use pma and pmg to visualize and preview the behavior of pmt. Every path through the graph created by pma (and drawn by pmg) is a trace (test run) that may be generated by pmt, when pma and pmt are invoked with the same arguments.

For more information, peruse the talks, read the overview and the more detailed notes, browse the code, or try the samples.

Here are the slides for a talk on PyModel at NWPD10.

You may download PyModel-0.9.tar.gz or PyModel-0.9.zip.

PyModel is also available at PyPI and GitHub.

PyModel requires Python 2.6 (because it uses itertools.product).

PyModel is influenced by NModel, but is not a translation or re-implementation.

PyModel is covered by the GNU General Public License (GPL). Code and documents are copyright (C) 2009, 2010, 2011 Jonathan Jacky.


Revised July 2010