Field with @Rule annotation must be public

java.lang.Exception
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, 2 months 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.com5 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