Red > Green > Refactor > Red

cycle is based on desire

JUnit 4 > org.junit.rules.ExpectedException のアクセス修飾子は public

表題通りそのままです

OK

  @Rule
  public final ExpectedException exception = ExpectedException.none();

NG

  @Rule
  protected final ExpectedException exception = ExpectedException.none();
  @Rule
  private final ExpectedException exception = ExpectedException.none();
org.junit.internal.runners.rules.ValidationError: The @Rule 'exception' must be public.
    at org.junit.internal.runners.rules.RuleMemberValidator$MemberMustBePublic.validate(RuleMemberValidator.java:222)
    at org.junit.internal.runners.rules.RuleMemberValidator.validateMember(RuleMemberValidator.java:99)
    at org.junit.internal.runners.rules.RuleMemberValidator.validate(RuleMemberValidator.java:93)
    at org.junit.runners.BlockJUnit4ClassRunner.validateFields(BlockJUnit4ClassRunner.java:196)
    at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:129)
    at org.junit.runners.ParentRunner.validate(ParentRunner.java:416)
    at org.junit.runners.ParentRunner.<init>(ParentRunner.java:84)
    at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:65)

Javadoc

ExpectedException (JUnit API)