use of org.junit.runners.model.TestClass in project junit4 by junit-team.
the class RuleMemberValidatorTest method rejectClassRuleInNonPublicClass.
@Test
public void rejectClassRuleInNonPublicClass() {
TestClass target = new TestClass(NonPublicTestWithClassRule.class);
CLASS_RULE_VALIDATOR.validate(target, errors);
assertOneErrorWithMessage("The @ClassRule 'temporaryFolder' must be declared in a public class.");
}
use of org.junit.runners.model.TestClass in project junit4 by junit-team.
the class RuleMemberValidatorTest method acceptMethodNonStaticTestRule.
@Test
public void acceptMethodNonStaticTestRule() {
TestClass target = new TestClass(TestMethodWithNonStaticTestRule.class);
RULE_METHOD_VALIDATOR.validate(target, errors);
assertNumberOfErrors(0);
}
use of org.junit.runners.model.TestClass in project junit4 by junit-team.
the class RuleMemberValidatorTest method rejectClassRuleThatIsImplemetationOfMethodRule.
/**
* If there is any property annotated with @ClassRule then it must implement
* {@link TestRule}
*
* <p>This case has been added with
* <a href="https://github.com/junit-team/junit4/issues/1019">Issue #1019</a>
*/
@Test
public void rejectClassRuleThatIsImplemetationOfMethodRule() {
TestClass target = new TestClass(TestWithClassRuleIsImplementationOfMethodRule.class);
CLASS_RULE_VALIDATOR.validate(target, errors);
assertOneErrorWithMessage("The @ClassRule 'classRule' must implement TestRule.");
}
use of org.junit.runners.model.TestClass in project junit4 by junit-team.
the class RuleMemberValidatorTest method rejectNonStaticClassRule.
@Test
public void rejectNonStaticClassRule() {
TestClass target = new TestClass(TestWithNonStaticClassRule.class);
CLASS_RULE_VALIDATOR.validate(target, errors);
assertOneErrorWithMessage("The @ClassRule 'temporaryFolder' must be static.");
}
use of org.junit.runners.model.TestClass in project junit4 by junit-team.
the class RuleMemberValidatorTest method rejectClassRuleMethodReturnsAnArbitraryObject.
/**
* If there is any method annotated with @ClassRule then it must return an
* implementation of {@link TestRule}
*
* <p>This case has been added with
* <a href="https://github.com/junit-team/junit4/issues/1019">Issue #1019</a>
*/
@Test
public void rejectClassRuleMethodReturnsAnArbitraryObject() throws Exception {
TestClass target = new TestClass(TestWithClassRuleMethodReturnsAnArbitraryObject.class);
CLASS_RULE_METHOD_VALIDATOR.validate(target, errors);
assertOneErrorWithMessage("The @ClassRule 'arbitraryObject' must return an implementation of TestRule.");
}
Aggregations