Now that we've seen the implementation, let's look at the tests.
As a testing framework we use JUnit 4.5 with the use of annotations and for the preparation of repositories before and after tests we employ DbUnit. (For details about JUnit see: http://www.junit.org, for details about DbUnit see: http://dbunit.sourceforge.net.)
The main class is AllTests
, marked with @RunWith(Suite.class)
to act as TestSuite
.
In the @SuiteClasses
annotation, we put the classes that contain the tests.
The annotated setup method with @BeforeClass
contains the initialization of Spring applicationContext
; the annotated tearDown
method with @AfterClass
destroys the ApplicationContext
and closes the DbUnit
connection.
The folders that contain the tests have packages identical to the classes. This is to have access to the classes that have visibility only for the package, so that the test classes can test their targets.
We have three main classes to perform the tests: first, the unit tests; second, the integration...