The year 2014 is almost over, and this means that it is time to publish the most popular blog posts that I wrote during this year. I selected these blog posts by using Google Analytics. I selected all blog posts that were published during 2014 and picked the blog posts that had the most page […] Read more
Integration Testing
When we are writing integration tests for a function that saves information to the database, we have to verify that the correct information is saved to the database. If our application uses Spring Framework, we can use Spring Test DbUnit and DbUnit for this purpose. However, it is very hard to verify that the correct […] Read more
If we are writing integration tests for an application that uses Spring Framework, we can integrate DbUnit with the Spring testing framework by using Spring Test DbUnit. However, this integration is not problem free. Often we have to insert null values to the database before our tests are run or verify that the value saved […] Read more
When we write tests for our data access code, we use datasets for two different purposes: We initialize our database into a known state before our data access tests are run. We verify that the correct changes are found from the database. These seem like easy tasks. However, it is very easy to mess things […] Read more
When we write unit tests that use mock objects, we follow these steps: Configure the behavior of our mock objects. Invoke the tested method. Verify that the correct methods of our mock objects were invoked. The description of the third step is actually a bit misleading, because often we end up verifying that the correct […] Read more
When we write tests for our data access code, we must follow these three rules: Our tests must use the real database schema. Our tests must be deterministic. Our tests must assert the right thing. These rules are obvious. That is why it is surprising that some developers break them (I have broken them too […] Read more