check errorcode with @rule in junit
问题 I found @Rule annotation in jUnit for better handling of exception. Is there a way to check error code ? Currently my code looks like (without @Rule): @Test public void checkNullObject() { MyClass myClass= null; try { MyCustomClass.get(null); // it throws custom exception when null is passed } catch (CustomException e) { // error code is error.reason.null Assert.assertSame("error.reason.null", e.getInformationCode()); } } But with use of @Rule , I am doing following : @Rule public