junit testing - assertEquals for exception
问题 How can I use assertEquals to see if the exception message is correct? The test passes but I don't know if it hits the correct error or not. The test I am running. @Test public void testTC3() { try { assertEquals("Legal Values: Package Type must be P or R", Shipping.shippingCost('P', -5)); } catch (Exception e) { } } The method being tested. public static int shippingCost(char packageType, int weight) throws Exception { String e1 = "Legal Values: Package Type must be P or R"; String e2 =