Skip to content

No Coverage for branch/stack containing call of System.exit() #117

Closed

Description

@DrVanScott

jacoco does not show full coverage for the following code. It's a bit strange that the call to System.out.println is not shown as covered, while the generation of the RuntimeExceoption from within callExit is.

public static void main(String[] args) {
    try {
        callExit(false);
        throw new RuntimeException();
    } catch (RuntimeException re) {
        System.out.println("test");
        callExit(true);
    }
}

public static void callExit(boolean exit) {
    if (exit) {
        try {
            throw new RuntimeException();
        } catch (RuntimeException re) {
            System.exit(1);
        }
    } else {
        String x = "bla";
    }
}

Activity

  1. marchof commented on Jul 22, 2013

    @marchof
    Member

    This is known limitation. Code which does not return -- which is the case for System.exit() -- is not shown as covered:

    See FAQ:

    Code with exceptions shows no coverage. Why?

    JaCoCo determines code execution with so called probes. Probes are inserted into the control flow at certain positions. Code is considered as executed when a subsequent probe has been executed. In case of exceptions such a sequence of instructions is aborted somewhere in the middle and not marked as executed.

  2. locked and limited conversation to collaborators on Jan 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions