Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Section A.3. Annotations and static imports added

A.3. Annotations and static imports added

JUnit 4.x is based on annotations, a concept introduced in JDK 1.5 along with static imports and some other features. This section lists those changes to the JUnit API.

A.3.1. @Before and @After annotations

If you remember, with JUnit 3.x we used to override the setUp() and tearDown() methods when we extended the junit.framework.TestCase class. These methods (or fixtures, as they’re called) are executed right before/after each of the tests gets executed. Their purpose is to execute some common logic before or after each of the tests. As we already mentioned (several times, at least), in JUnit 4.x you no longer extend the junit.framework.TestCase class. So how can we execute some common logic before/after each of the tests?


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint