[TIP] condition coverage?

Dan Stromberg dstromberglists at gmail.com
Tue May 31 09:59:24 PDT 2016


On Tue, May 31, 2016 at 9:41 AM, Florian Bruhin <me at the-compiler.org> wrote:

> * Dan Stromberg <dstromberglists at gmail.com> [2016-05-31 09:17:33 -0700]:
> > I'm looking for a way of getting a condition coverage report for python
> > code.
> >
> > We've been using coverage.py .
> >
> > coverage.py appears to, at best, give branch coverage in its HTML report.
> > However, it's beginning to look like coverage.py can give condition
> > coverage (which is what we prefer). but only via its XML report.
> >
> > Is that accurate?
>
> I don't think so.
>
> AFAIK there's a blogpost by Ned Batchelder about why he hasn't been
> able to implement this, but I can't find it right now...
>

I'm puzzled by this:
$ egrep condition coverage.xml | head -5
                                                <line branch="true"
condition-coverage="50% (1/2)" hits="1" missing-branches="24" number="23"/>
                                                <line branch="true"
condition-coverage="50% (1/2)" hits="1" missing-branches="29" number="28"/>
                                                <line branch="true"
condition-coverage="50% (1/2)" hits="1" missing-branches="99" number="98"/>
                                                <line branch="true"
condition-coverage="50% (1/2)" hits="1" missing-branches="36" number="14"/>
                                                <line branch="true"
condition-coverage="100% (2/2)" hits="1" number="18"/>

$ rm coverage.xml

$ ./bin/jenkins-test > /dev/null 2>&1

$ egrep condition coverage.xml | head -5
cmd output started 2016 Tue May 31 09:52:23 AM PDT
                                                <line branch="true"
condition-coverage="50% (1/2)" hits="1" missing-branches="24" number="23"/>
                                                <line branch="true"
condition-coverage="50% (1/2)" hits="1" missing-branches="29" number="28"/>
                                                <line branch="true"
condition-coverage="50% (1/2)" hits="1" missing-branches="99" number="98"/>
                                                <line branch="true"
condition-coverage="50% (1/2)" hits="1" missing-branches="36" number="14"/>
                                                <line branch="true"
condition-coverage="100% (2/2)" hits="1" number="18"/>

./bin/jenkins-test is using nose with --with-coverage - so via the
coverage.py plugin .

Note the presence of the string "condition-coverage".

Also, coverage.py's xmlreport.py has:
                    xline.setAttribute(
                        "condition-coverage",
                        "%d%% (%d/%d)" % (100*taken/total, taken, total)
                        )


Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20160531/8117b8f7/attachment.htm>


More information about the testing-in-python mailing list