Reading JSON Files to Create Test Versions of REST Clients

This post describes a simple way to create a test version of a service that reads JSON or XML from a REST service or similar. The purpose is to easily create a fake service that reads from files instead and that can be used for testing other code that use the service. I believe in … Continue reading Reading JSON Files to Create Test Versions of REST Clients

Writing an Integration Test First for RabbitMQ

In a previous post, we saw some Java code for redelivering messages from a queue to an exchange in RabbitMQ. Obviously, a test was written before writing the actual code. What kind of test is appropriate in this situation? What we want to test is that messages that are in a RabbitMQ queue are removed … Continue reading Writing an Integration Test First for RabbitMQ

Testing Spring Data JPA and In-Memory Repositories Using DbUnit

In a previous post, we saw how to create Spring Data JPA repositories, and how to create in-memory versions of these repositories, useful for testing other code that uses repositories. Obviously, the repositories themselves need to be tested. DbUnit can be used to populate a database with test data so that we know the state … Continue reading Testing Spring Data JPA and In-Memory Repositories Using DbUnit

Creating In-Memory Versions of Spring Data JPA Repositories for Testing

This post shows how to easily create in-memory versions of your repositories. These in-memory repositories can then be injected into, for example, a service that you want to test. I am not a big fan of mocking frameworks. The reason is that I believe that it is far too easy to oversimplify the interactions between … Continue reading Creating In-Memory Versions of Spring Data JPA Repositories for Testing