Hello,
In the report it says 1 of 2 branches missed for the below conditions checks in the code
if (Objects.nonNull(xssFilter))
if (Objects.nonNull(httpResponse))
Please let me know how could make it work 100% coverage for the above conditions
Thanks,
Srinivas
Views
Replies
Total Likes
Hi @Srinivas_Opti ,
To have the perfect testsuite, you need to write test cases for the negative scenarios as well.
Considering your code for instance:
if (Objects.nonNull(xssFilter))
if (Objects.nonNull(httpResponse))
You might have written test case if this conditions hold true, but you also need to write test cases for false conditions:
Here, if xssFilter is null and/or httpResponse is null what should happen ?
Hope this helps!
Best Regards,
Milind Bachani
if I set @Mock
XSSFilter xssFilter;
Then Objects.nonNull(xssFilter) is never null
If set xssFilter=null is not getting failing the if check
How to resolve the issue
Thanks
@Srinivas_Opti if you are using AemContext(), you should be able to use:
@Mock
XSSFilter xss;
context.registerService(XSSFilter.class, xss);
@Srinivas_Opti Can you post the code that has issues ?
Views
Like
Replies
Views
Likes
Replies