Skip to content
This repository was archived by the owner on Dec 31, 2019. It is now read-only.
This repository was archived by the owner on Dec 31, 2019. It is now read-only.

Else path not taken #127

@Gopikrishna19

Description

@Gopikrishna19

Hello

I ran into a weird issue: when I have the following setup,

if(!array.length) {
  return null;
}

return doSomething();

It reported that else path is not taken:
epnt1

I am testing the else part too, by asserting doSomething is called. I refactored the code to the following:

if(!array.length) {
  return null;
} else {
  return doSomething();
}

which ended up with following report:
epnt2

Once again I refactored the code:

let returnValue;

if(!array.length) {
  returnValue = null;
} else {
  returnValue = doSomething();
}

return returnValue;

which resulted in 100% coverage. Can I please know what is wrong with first or second code pattern? why would it say that the else path was not taken, even though there are 'hits' on those lines of code? is this a bug or by design? Though I can somewhat digest the first one, I would say the second one is a real bug!

(I have cut many things inside the braces in the images to simplify stuff, the code given is the (pseudo)real one)

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