[Baypiggies] How to determine what unit tests cover a code change?
Minesh B. Amin
mamin at mbasciences.com
Wed Feb 2 21:17:07 CET 2011
Let me preface what follows by stating that, when it comes to
"optimizing" how testing is done, any solution must produce no
false positives, and no false negatives. Otherwise, the "optimizing"
part would be self-defeating.
To gather the most accurate snapshot of the actual dependencies
(that includes both python and non-python data/text/script files):
+ each unittest must be run in a stand-alone session ... the
goal is to force each unittest to import whatever it wants;
+ invoke each session as:
strace -f -e trace=open python <unittest>.py
and post-process the output produced
Couple of issues to keep in mind:
+ strace may produce relative paths which would need to be
+ in case this flow is too resource intensive (in terms of CPU time),
you may want to bundle the unittests according to some criteria.
On Wed, 2011-02-02 at 11:18 -0800, Lincoln Peters wrote:
> 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?
More information about the Baypiggies