I am using mockk library in Kotlin. I am covering branch coverage. I am new to testing. Can someone tell me how to cover all branches? In the given below example, it has two objects one is id as string and the name which is hidden is list. Thanks
Can someone explain what are the 12 branches are for this?
CodePudding user response:
I can only count 9, but I might be missing something:
!id.isNullOrEmpty() | Reason | !xxx.isNullOrEmpty() | Reason |
---|---|---|---|
TRUE | id is not null and not empty | TRUE | xxx is not null and not empty |
TRUE | id is not null and not empty | FALSE | xxx is empty |
TRUE | id is not null and not empty | FALSE | xxx is null |
FALSE | id is null | TRUE | xxx is not null and not empty |
FALSE | id is empty | TRUE | xxx is not null and not empty |
FALSE | id is null | FALSE | xxx is null |
FALSE | id is null | FALSE | xxx is empty |
FALSE | id is empty | FALSE | xxx is null |
FALSE | id is empty | FALSE | xxx is empty |