how to handle exceptions in junit
An unexpected exception is a test failure, so you neither need nor want to catch one. @Test public void canConvertStringsToDecimals() { String str = “1.234”; Assert.assertEquals(1.234, service.convert(str), 1.0e-4); } Until service does not throw an IllegalArgumentException because str has a decimal point in it, that will be a simple test failure. An expected exception should … Read more