Search This Blog

Thursday, November 15, 2012

Notes on JUnit @After Annotation


Notes on JUnit @After Annotation:

  • All methods marked with @After are executed
  • The method named tearDown executes even if it's not marked as @After
  • @After annotation is not inheritable so you need to add @After if you override the annotated method
  • Remember to call super.tearDown if you override tearDown in you class
  • For class hierarchies it is best to use different clean-up methods with different names, marked with @After, so they're all called automatically and you won't accidentally override them.

No comments:

Post a Comment