stefanbirkner / system-rules

A collection of JUnit rules for testing code which uses java.lang.System.
http://stefanbirkner.github.io/system-rules
Other
546 stars 71 forks source link

RestoreSystemProperties could work also at a class level #20

Closed szpak closed 10 years ago

szpak commented 10 years ago

It is sometimes useful to have RestoreSystemProperties abilities at a class level. System properties should be restored to the state before the first @BeforeClass method after all tests and all @AfterClass methods are executed.

Simple use case. Testing logic related to system properties inside a Spring context which is created in @BeforeClass method.

It would be important to have support for putting the rule in a super class extended by many test specifications.

I don't know JUnit internals and I am not sure if the same rule can work on both test/method and class level or a new rule would have to be created.

stefanbirkner commented 10 years ago

You can use the rules as class rules, too. I added this advice to System Rules' homepage.

szpak commented 10 years ago

Thanks Stefan, I didn't know about that.