[Baypiggies] How to determine what unit tests cover a code change?

Lincoln Peters anfrind at gmail.com
Wed Feb 2 20:18:50 CET 2011

I work on a project with thousands of unit tests, implemented using
the built-in "unittest" module, and it takes about five hours to run
the full suite.  If I know which source files changed since I last ran
the unit tests, does anyone know of a good way to determine which unit
tests cover those source files and only run those?

The individual test cases are spread across about 150 subclasses of
TestCase, some of which define dozens of test methods, and for the
most part each class is in its own module (there are a few cases where
two subclasses of TestCase are in the same module, e.g. if one derives
from the other and changes something about how the tests run).  My
best idea thus far is to use the "inspect" module to look at what each
test module imports and figure out if a changed file gets imported at
any point.  But I wouldn't be at all surprised if there's an existing
tool that does that, or if there's a better way that I haven't thought


Lincoln Peters
<anfrind at gmail.com>

More information about the Baypiggies mailing list