@Test public void methodRejectArbitraryObjectWithRuleAnnotation() throws Exception { TestClass target = new TestClass(MethodTestWithArbitraryObjectWithRuleAnnotation.class); RULE_METHOD_VALIDATOR.validate(target, errors); assertOneErrorWithMessage( "The @Rule 'getArbitraryObject' must return an implementation of MethodRule or TestRule."); }
@Test public void rejectMethodStaticTestRule() { TestClass target = new TestClass(TestMethodWithStaticTestRule.class); RULE_METHOD_VALIDATOR.validate(target, errors); assertOneErrorWithMessage( "The @Rule 'getTemporaryFolder' must not be static or it has to be annotated with @ClassRule."); }
@Test public void methodAcceptMethodRuleMethod() throws Exception { TestClass target = new TestClass(MethodTestWithMethodRule.class); RULE_METHOD_VALIDATOR.validate(target, errors); assertNumberOfErrors(0); }
@Test public void acceptMethodNonStaticTestRule() { TestClass target = new TestClass(TestMethodWithNonStaticTestRule.class); RULE_METHOD_VALIDATOR.validate(target, errors); assertNumberOfErrors(0); }