Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 8
    +1 You can also annotate a method with @Rule, so this would avoid the problem. You should add this to your answer. Commented Jan 15, 2013 at 11:12
  • Thanks Matthew, I did not know that. Apparently new functionality in 4.11. Commented Jan 15, 2013 at 11:40
  • @KErlandsson - are You completely sure about that? This is what the JUnit API documentation states: "A field must be public, not static, and a subtype of TestRule (preferred) or MethodRule" Commented Nov 18, 2015 at 9:01
  • @dziki What do you refer to? Am I sure about what exactly? Commented Nov 18, 2015 at 12:00
  • But if it uses reflexion, it should be able to work with private fields. Not sure why it does not. Commented Nov 27, 2024 at 12:53