I’m running a pit mutation test for my function and I can’t seem to cover this line for the negated conditional. So it’s a if statement that does a substring to build a url for the service call.
public List<Player> retrievePlayers(List<String> playerIds) throws error {
List<Player> players = new ArrayList<Player>();
ResponseEntity<String> playerDetails;
String currentPlayerId = null;
for(String playerId : playerIds) {
currentPlayerId = playerId;
if (playerId.length() == 15) {
currentPlayerId = playerId.substring(0,10);
}
}
try {
playerDetails = playerFetchDelegate.getPlayerDetails(currentPlayerId);
convertResponseToObject(playerDetails, players);
} catch (exception) {
throw new exception
}
}
return players;
}
So the mutation is not covering the if statement because the condition doesn’t change the return. How can I cover the line?
Thanks!