In more complex applications (that use a database, for example), there is often the need to set up the data before each test and clean it up after the test is completed. Some parts of the data need to be set before each test method and/or cleaned after each test method has completed. Other data may need to be set up before any test method of the test class was run and/or cleaned up after the last test method of the test class has completed.
Using fixtures to populate data for testing
How to do it...
To accomplish this, you add an @Before annotation in front of it, which indicates that this method has to run before every test method. The corresponding cleaning method is identified by the @After annotation. Similarly, the class...