### Question:
CheckerWithException { public int checkValue(final int amount) { if (amount == 0) { throw new IllegalArgumentException("value is 0"); } return 0; }  int checkValue(final int amount);  }### Answer:
@Test public void checkValueTerseWay() throws Exception { try { checkerWithException.checkValue(0); fail("Expected exception for zero length"); } catch (IllegalArgumentException e) { assertTrue("expected", true); } }
@Test(expected = IllegalArgumentException.class) public void checkValueTerseWay2() throws Exception { checkerWithException.checkValue(0); }
@Test public void checkValueBetterWay() throws Exception { assertThrows(IllegalArgumentException.class, () -> checkerWithException.checkValue(0)); }