The method below has 3 possible paths: 1. True, 2. False, 3. Exception.
To test it, I need to mock the private getWootsWithAvailableProducts
for the True
and Exception
paths. However, the collective wisdom seems to be saying you should not mock private methods. How else can I test those paths if I don't mock the private method. I need to spy on it for verification. If that's all true, why is it so hard to mock private methods. If its not true, what am I missing?
Under test:
public List<Woot> findAllWoots(final boolean isBuy) throws Exception {
final List<Woot> allWoots = wootService.findAllWoots();
return isBuy ? getWootsWithAvailableProducts(allWoots) : allWoots;
}
Aucun commentaire:
Enregistrer un commentaire