Timeline for Does it make sense to measure conditional coverage for Java 8 code?
Current License: CC BY-SA 3.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Dec 2, 2016 at 15:13 | comment | added | Andres F. |
@MikePartridge Yes, but the point is that this isn't done via branch coverage. Branch coverage is needed when writing if-else because each of those constructs is completely ad-hoc. In contrast, Optional, orElse, map, etc, are all already tested. The branches, in effect, "vanish" when you use more powerful idioms.
|
|
| Dec 2, 2016 at 13:33 | comment | added | Mike Partridge |
@AndresF. I don't think Karol is suggesting that we test Optional. Like he said, logically we should still test that getName() handles various possible inputs in the way we intend, regardless of its implementation. It's harder to determine this without code coverage tooling helping in the way it would pre-JDK8.
|
|
| Dec 1, 2016 at 23:22 | comment | added | Andres F. |
@KarolLewandowski I think what Shaz is saying is that if you trust how Optional (and related methods) work, you no longer have to test them. Not in the same way you tested an if-else: every if was a potential minefield. Optional and similar functional idioms are already coded and guaranteed not to trip you over, so essentially there's a "branch" that vanished.
|
|
| Dec 1, 2016 at 22:32 | comment | added | Karol Lewandowski |
"That they no longer exist in Java 8..." - I can't agree with it, Java 8 is backward compatible and if and null are still parts of the language ;-) It's still possible to write code in old way and to pass null user or user with null name. Your tests should just prove that contract is met regardless of how method is implemented. The point is that there is no tool to tell you if you fully tested contract.
|
|
| Dec 1, 2016 at 22:24 | history | edited | Shaz | CC BY-SA 3.0 |
terminology correction
|
| Dec 1, 2016 at 22:09 | history | answered | Shaz | CC BY-SA 3.0 |