Field with @Rule annotation must be public

java.lang.Exception
Javadoc
The class {@code Exception} and its subclasses are a form of {@code Throwable} that indicates conditions that a reasonable application might want to catch.

The class {@code Exception} and any subclasses that are not also subclasses of {@link RuntimeException} are checked exceptions. Checked exceptions need to be declared in a method or constructor's {@code throws} clause if they can be thrown by the execution of the method or constructor and propagate outside the method or constructor boundary. @author Frank Yellin @see java.lang.Error @jls 11.2 Compile-Time Checking of Exceptions @since JDK1.0

at org.junit.internal.runners.rules.RuleFieldValidator.addError

Typical Exception Messages

  1. The @Rule 'mActivityRule' must be public.
  2. The @Rule '_gebReportingSpecTestName' must implement MethodRule or TestRule.
  3. The @Rule 'context' must implement MethodRule or TestRule.
  4. The @Rule 'testName' must be public.
  5. The @Rule 'loginRule' must implement MethodRule or TestRule.
  6. The @Rule 'recorder' must implement MethodRule or TestRule.
  7. The @Rule 'rule' must not be static.

Specific cases

Solution

JaviRpo, 1 month ago

JUnit has basic rules with its main annotations, in this case, if you have a field with the @Rule annotation, this field must be public and non-static

External results for this pattern (6)

  1. The @Rule 'mActivityRule' must be public.
    Show stack trace
  2. Unknown authorvia blogspot.com3 months ago
    The @Rule 'mActivityRule' must be public.
    Show stack trace
  3. The @Rule 'testName' must be public.
    Show stack trace
  4. falkovia GitHub1 year ago
    The @Rule 'rule' must not be static.
    Show stack trace
  5. The @Rule '_gebReportingSpecTestName' must implement MethodRule or TestRule.
    Show stack trace
  6. tobywestonvia GitHub2 years ago
    The @Rule 'context' must implement MethodRule or TestRule.
    Show stack trace