Allow branch coverage

Issue #1 wontfix
created an issue

I know it is possible to activate branch coverage using a config file, but I'd like to use branch coverage with a command-line option. Perhaps something like:

{{{ py.test --cov-report term-missing --cov --branch myproj tests/ }}}


{{{ py.test --cov-report term-missing --covbranch myproj tests/ }}}

Another possibility would be to make branch coverage the default.


Comments (7)

  1. memedough repo owner

    I'm cross posting to pytest and coverage to discuss.

    At the start pytest-cov had command line options to control all of coverage.

    Talk on pytest mailing list there was concern about so many options and that it should have minimal options. That way py.test --help output is shorter and more useful as a single plugin doesn't output huge amounts of text hiding the other plugin help text. Also it could be fully controlled through coverage config file.

    We could add a small number of options in but I'd like to get others opinions first. Plus how do we decide which ones should be in or not. If we add branch then maybe someone else wants timid or cover pylib.

    Another thing to consider is should coverage have env vars for all of it's options. That way it could be controlled from the command line but independent of the test runner (pytest, nose, unittest2) and so it would work with all of them. Something like:

    COVERAGE_BRANCH=1 py.test --cov-report term-missing --cov myproj tests/

    Or the following as coverage already reads COVERAGE_OPTIONS to get timid option:

    COVERAGE_OPTIONS="--branch" py.test --cov-report term-missing --cov
    myproj tests/

    These days I quite like the minimal options with full control through config file. But I do see that it is nice to control through the command line which is why I had full control of every option at the very beginning (in fact I had command line option, env var, then config file for each option).

    Any ideas on leaving it as it is? Adding small number of options to pytest-cov? Adding env vars to coverage to control independently so works will all test runners?

  2. jimslack reporter

    Branch coverage is so much better than the default statement coverage (see nearly any book on software testing), that I think it should be the default. However, having an option for branch coverage is better than making testers jump through hoops to get it.

  3. memedough repo owner

    I'm sorry, as much as I'd like to have branch coverage available easily on the command line it does raise all the pass through issues, plus the one plugin taking up more pytest help space.

    The command line options I think are very minimal and nice. --cov set's a source tree root, can have any number. --cov-report produces a report, can have any number. --cov-config set's the config file for full control over all coverage features.

    I'll leave this for a while and see if there is anymore comments on the mailing lists. I'm also considering branch on by default but I think that will mean that it can't be turned off.

  4. memedough repo owner

    I saw branch coverage is not actually working correctly and issue raised on coverage project.

    That is good reason to follow the default setting off and allow turning on with config file. Then branch coverage can be on or off, better than forced always on.

  5. Log in to comment