Jackson Tale
Jackson Tale

Reputation: 25812

How does Jenkins code coverage work?

I am using Jenkins to build and monitor the testing for my application.

I have such a piece of python code:

def register_os_handler():
    def handler(signal, frm):
        raise SystemExit()
    signal(SIGHUP, handler)

In my test, I create a subprocess, and send it a SIGHUP signal and it quits as expected, which means it reaches the line of raise SystemExit().

When I submit it to Jenkins, all tests passed, but it says the line raise SystemExit() is not covered.

I feel curious that why that line was indeed reached, but still Jenkins complains?

  1. How does the Jenkins' coverage report work?

  2. If a process (even if it is a subprocess) quits, it cannot detect the line or take the line into account?

  3. How to get around this?

Upvotes: 3

Views: 1807

Answers (1)

zefciu
zefciu

Reputation: 2046

I believe Jenkins uses coverage.py. If you want to compute coverage for subprocess, you need a little hack, which is described here:

http://nedbatchelder.com/code/coverage/subprocess.html

Upvotes: 1

Related Questions