In earlier version of Junit, we need to declare @SetUp and @TearDown for each test class.
Now, with newer version of Junit, it’s possible to define its own rule with @Rule and you will have the possibility to execute code during test (Same thing than AOP).
To help you to understand, here is some standard rules :
- ExpectedException: check if an exception is thrown during test
- Timeout: check that one test doesn’t exceed a given time
- ExternalResource: Open or close a resource.
- TemporaryFolder: create and destroy a temporary directory.
Ref :
http://blog.objetdirect.com/divers/quoi-de-neuf-chez-junit
http://www.dzone.com/links/r/junit_rules_3.html
No comments:
Post a Comment