[TIP] Model checking Python code
ned at nedbatchelder.com
Sat Sep 5 08:34:13 PDT 2009
Matt Harrison wrote:
> On Sat, Sep 5, 2009 at 6:17 AM, Ned Batchelder<ned at nedbatchelder.com> wrote:
>> I'm still confused by the term "linear combinations of paths". What would a
>> non-linear combination of them be? Why don't people just say, "combinations
>> of paths"?
> Check out McCabe's papers. At a minimum they are worth it for the
> mugshot at the end. Here's the original, 33 years old now. It
> explains the theory. Here's a newer (a much longer) testing strategy
> one thats only about 13 years old. It gives more examples.
> I'm actually re-working that talk now to give at a local open source
> conference. Maybe I'll try and get the information out in a
> magazine article. Barring that I can put it on my blog.
> 0 - http://classes.cecs.ucf.edu/eel6883/berrios/notes/Paper%204%20(Complexity%20Measure).pdf
> 1 - http://www.mccabe.com/iq_research_nist.htm
> 2 - http://2009.utosc.com/presentation/92/
While we're on the theory of the matter, I'm also a bit troubled by the
omission in these papers of exception throwing. Consider this C function:
int foo(int a)
return f1(a) + f2(a) + f3(a);
It has a cyclomatic complexity of 1. Now look at a similar function in
return f1(a) + f2(a) + f3(a)
If any of f1, f2, or f3 can raise an exception (and in Python any one of
them can), then doesn't this have a complexity of 4? And if we're
trying to measure paths executed, we're a bit stuck, because it might be
that in fact f2 never raises an exception, so the "f2 raised" path will
never be executed, and that's not a fault in the test suite, it's a lack
of understanding of the system by the coverage tool.
Ned Batchelder, http://nedbatchelder.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the testing-in-python