-
Type:
Suggestion
-
Resolution: Won't Fix
-
Component/s: Groovy
-
None
-
Environment:Suse linux
Currently any usage of the groovy safe operator requires that that reference be tested with a null and non-null value. This adds significant overhead in the case where multiple calls are chained together with the safe operator. It would be more useful as a coverage measurement if the chain was treated as one call.
Look at the following line as an example.
def value = a.getB()?.getC()?.getD()?.getE()
This line of code should require a test that sets value to null and a test that sets value to something non-null. It should not however require a test where B is null a test where c is null a test where d is null and a test where e is null to reach 100% conditional coverage.
While I hope that lines that look like the above are not written very often, it still could happen, and having to write a bunch of tests to cover one line seems like a heavy burden.