2

I'm using the library System Rules to testing method that calls System.exit():

@Rule
public final ExpectedSystemExit exit = ExpectedSystemExit.none();

Unfortunately, this piece of code is causing the error ...

initializationError caused an ERROR: org/junit/rules/TestRule

I'm using JUnit 4.7 and System Rules 1.2.0.

Aleksander Blomskøld
  • 18,374
  • 9
  • 76
  • 82
  • Could you post more of your class. I'm using SystemRules just like this and everything seems to be fine. – Will Jan 13 '13 at 15:33
  • I suspect, that the issue of my problem may be configuration of NetBeans, but I added appropriate jar files to "Test libraries". – user1974304 Jan 13 '13 at 15:40

2 Answers2

2

System Rules needs at least version 4.9 of JUnit.

(I add this information to System Rules' homepage. Thank you for posting your question.)

Stefan Birkner
  • 24,059
  • 12
  • 57
  • 72
0

System Rules seems to want the following dependencies

  • junit-4.11-beta-1

hth

Will
  • 6,179
  • 4
  • 31
  • 49
  • I added hamcrest-core-1.3.jar to "Test Libraries" but the problem still exists. This must be a mistake in my configuration of Netbeans, because it does not work properly even for very simple classes. – user1974304 Jan 13 '13 at 15:50
  • 1
    The issue of my problem was JUnit 4.7. Using version 4.11, everything works fine. Thanks a lot. – user1974304 Jan 13 '13 at 16:34
  • Cool. I didn't run into any of these headaches because I'm using Maven, and it just figures everything out (mostly) for you. :) – Will Jan 13 '13 at 16:35