Reputation: 471
I have a portion of code with three booleans, connected via "&&" like so:
bool1 && bool2 && bool3
During testing I debugged to this and found out that every boolean has a state of either true or false during all of the tests, so I would consider this sufficiently tested.
However, eclemma shows, that there is 1 of 6 branches, which is not covered.
As I found out by now, it is not possible to show which branch eclemma means (unfortunately), but I would additionally like to know, how eclemma reaches 6 branches?
From what I can see there are two possibilities:
1. use code optimization, so the evaluation of that expression is stopped after reaching the first "false", in this case, I would find 4 total states:
- false
- true - false
- true - true - false
- true - true - true
2. don't use code optimization, so in this case I would think that all 8 different states of the three booleans can be tested (2 * 2 * 2 = 8).
Can anyone help me out there, why eclemma is counting to 6 and what I can do to reach 100% test coverage?
Upvotes: 2
Views: 5680
Reputation: 1
If you'll write all 4 test cases as per your 1st possibility, it'll give you 100% coverage.
Upvotes: 0