Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run coverage in branch mode. #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

georgedorn
Copy link

Saw your article. Thought you might be interested in seeing if you have complete branch coverage as well.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling dd61109 on georgedorn:patch-1 into 97a0cf4 on peterbe:master.

@peterbe
Copy link
Owner

peterbe commented Aug 25, 2014

What's what for?
There's only ever one branch and that's master. What am I missing?

@georgedorn
Copy link
Author

Branch coverage tests whether both code paths of a branch have been
executed.

https://en.wikipedia.org/wiki/Code_coverage#Basic_coverage_criteria

On Sun, Aug 24, 2014 at 8:54 PM, Peter Bengtsson [email protected]
wrote:

What's what for?
There's only ever one branch and that's master. What am I missing?


Reply to this email directly or view it on GitHub
#76 (comment).

@peterbe
Copy link
Owner

peterbe commented Aug 25, 2014

Ah. it's not for git branches. Me==silly.

But I still don't understand how this is different? If you have:

if condition:
   then_this()
else:
  then_that()

If both the if and the else statement is covered, it'll give you 4 out of 4 lines of test coverage. What would branch coverage add?

@georgedorn
Copy link
Author

Statement coverage works the same as branch coverage so long as you always have an else clause.

Imagine this code:

if condition:
  do_something()

If condition is always true in all of your tests, statement coverage will tell you your coverage is complete. Branch coverage will inform you that you don't have a test for when condition is false.

@peterbe
Copy link
Owner

peterbe commented Aug 26, 2014

But in the case of

if condition:
  do_something()
do_something_else()

if you have 3 lines test coverage you don't need branch coverage, right?

@peterbe
Copy link
Owner

peterbe commented Aug 26, 2014

Also, in python might have this:

def can_view(age):
    if age > 18:
        return "sure"

Suppose that your tests call can_view(17) and can_view(19) then do you get insufficient branch coverage?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants