Skip to content
This repository was archived by the owner on Mar 26, 2021. It is now read-only.
This repository was archived by the owner on Mar 26, 2021. It is now read-only.

condition coverage #37

Open
Open

Description

@zhouyulin

I want to get the condition coverage report, it seems that only line coverage can be reported.

Activity

  1. dylanb commented on Mar 17, 2015

    @dylanb
    Owner

    I think what you are looking for is what I refer to as "statement coverage". This is reported by the tool along with chainable coverage - which is an expanded form of branch coverage because it covers tracking chained calls that do not have any effect (e.g. they pass in empty lists and they call code that is in a library and therefore has no coverage tracking).

    Look at the example report and you will see that some of the conditions in the if statement and the ternary are shown as not being covered.

  2. zhouyulin commented on Mar 18, 2015

    @zhouyulin
    Author

    Thank you so much for responding so quickly.
    Statement coverage which you say it should be the C1 coverage(branch coverage).
    But I want to get the C2 coverage .(http://www.slideshare.net/hiroppie/test-coverage)
    If this tool support C2 coverage , could you tell me how to set the option command?

  3. dylanb commented on Mar 18, 2015

    @dylanb
    Owner

    Here is a module that has the four different conditions

    module.exports = function () {
        var a = false, b = false;
    
        if (a && b) {
            console.log('a && b');
        }
    
        a = true;
    
        if (a && b) {
            console.log('a && b');
        }
    
        b = true;
        a = false;
    
        if (a && b) {
            console.log('a && b');
        }
    
        a = true;
        b = true;
    
        if (a && b) {
            console.log('a && b');
        }
    };

    If I run the coverage report on that, I get the following:

    image

    As you can see, it shows exactly which of the elements of the if statement were executed. It also shows how many times each statement was executed, what it does not show is when each condition did pass, but not every pass through the if statement evaluated to true, whether some of the failures were due only to the second condition failing, or whether they were all due to the first failing.

    So it comes close, but no cigar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions