I can't seem to be able to access the Exception in the method for a JUnit test. Here is the method:
public void doUpdateStocks() {
for (Entry<Integer, IFolioRestricted> e : folioList.entrySet()) {
IFolioRestricted folio = e.getValue();
for(Entry<Integer, IStockRestricted> s : folio.getStockList().entrySet()){
try {
((IStock) (s.getValue())).updatePrice();
} catch (MethodException e1) {
e1.printStackTrace();
}
}
}
And this is how I am testing it:
@Test
public void testUpdateStock() {
h.doCreateNewFolio("a");
try {
h.doBuyStock(0, "A", 10);
} catch (IOException | WebsiteDataException | NoSuchTickerException | MethodException e) {
// TODO Auto-generated catch block
}
h.doUpdateStocks();
}
After looking online I have seen (expected = MethodException.class) however it doesn't seem to work. Anyone any ideas on how to cover the catch (MethodException e1) { e1.printStackTrace(); } in a JUnit?
Aucun commentaire:
Enregistrer un commentaire