2
votes

I'm adding cobertura code coverage for my grails 3.1.6 project, the coverage report seems to be bit off, i.e I have unit test cases ( both pos & neg case) to cover a if block, but the report says no coverage for that if -block. Gradle: 2.13 Groovy: 2.4.5 grails: 3.1.6 cobertura gradle plugin: net.saliman:gradle-cobertura-plugin:2.3.2

Here is my code

if (params == null || params.isEmpty()) {
       return []
}

My unit test pass empty params and null for params

coverage report say

'Conditional coverage: 0% 0/6 [each condition: 0%, 0%, 0% ]'

any idea what I'm doing wrong ?

Thanks in advance

1

1 Answers

-1
votes

It might be late. But the reason being that the "If" is an conditional check. So in other to increase this. The Params should be tested with Null and Also empty so that implies both conditions will have to be resolved and once it should skip the entire if block so that becomes 3 conditions.