Sathish David Kumar N
asked on
How to write code coverage for lambda preparestatement
How to right code coverage for preparedStatment lambda action
this.jdbcTemplate.query(sq lQuery, (PreparedStatementSetter) ps -> {
ps.setTimestamp(1, startTime);
ps.setTimestamp(2, endTime);
ps.setString(3, status);
ps.setString(4, Constants.SUCCESS);
}, new CountResultSet()).intValue ();
this.jdbcTemplate.query(sq
ps.setTimestamp(1, startTime);
ps.setTimestamp(2, endTime);
ps.setString(3, status);
ps.setString(4, Constants.SUCCESS);
}, new CountResultSet()).intValue
ASKER
sorry How to write code coverage for Lambda expression
Ok, I thought that you may have meant "write" too, but still it doesn't make any sense. You don't "write" code coverage. Your code is either covered by test case(s) or not. Since I am guessing it may just be a language issue, can you try asking for what you want in another way?
ASKER
yes your correct .
example
return this.jdbcTemplate.query(sq lQuery, (PreparedStatementSetter) ps -> {
ps.setTimestamp(1, startTime);
ps.setTimestamp(2, endTime);
// still 5 more line
}, new CountResultSet()).intValue ();
My test case does not cover
ps.setTimestamp(1, startTime);
ps.setTimestamp(2, endTime);
// still 5 more line
I need to cover this 7 line how to do that
example
return this.jdbcTemplate.query(sq
ps.setTimestamp(1, startTime);
ps.setTimestamp(2, endTime);
// still 5 more line
}, new CountResultSet()).intValue
My test case does not cover
ps.setTimestamp(1, startTime);
ps.setTimestamp(2, endTime);
// still 5 more line
I need to cover this 7 line how to do that
As long as your test case is calling the actual query() method call, then PreparedStatementSetter lines will get called to.
Perhaps your code coverage tool is just not indicating what lines have been called properly, and maybe this is because it can't handle the lambda syntax properly. Just as a verification of the above, if you change your code from a lambda to the "old" way using an anonymous inner class, do the lines show up as being covered? If so, you may need to see if your code coverage tool has an update that might be able to handle lambda's properly.
Perhaps your code coverage tool is just not indicating what lines have been called properly, and maybe this is because it can't handle the lambda syntax properly. Just as a verification of the above, if you change your code from a lambda to the "old" way using an anonymous inner class, do the lines show up as being covered? If so, you may need to see if your code coverage tool has an update that might be able to handle lambda's properly.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What do you mean by this? It doesn't really make much sense to me.