lundi 11 octobre 2021

Why does this else condition not meet code coverage?

I'm confused about why the following if/else condition doesn't meet code coverage. Specifically the else is getting flagged as not having coverage.

if (myBoolean) {
    myComponent.myElement = 'Hello world';
} else {
    myComponent.myElement = 'Hello everyone';
}

I can refactor this to set the value of myComponent.myElement prior to the if condition, and that seem to pass fine.

myComponent.myElement = 'Hello everyone';
if (myBoolean) {
    myComponent.myElement = 'Hello world';
}

Why wouldn't the else condition pass as well?

Aucun commentaire:

Enregistrer un commentaire