Database Integration Testing with Testcontainers

Introduction to Testcontainers In this post we'll look at Testcontainers and how it can be used to spin up throwaway test databases for your integration tests. You'll see that Testcontainers offers an excellent alternative to in memory databases, such as H2. In memory databases have benefits in terms of speed and simplicity, but there's one fundamental drawback. Your integration tests use a database technology that is substantially different to the one your application will use in production. Testcontainers allows you to spin up the database of your choice, so that your persistence tests run against the same database technology that you'll use in production. This makes [...]

By |2021-10-27T23:29:49+01:00October 27th, 2021|Containerisation, Spring Boot, Testing|0 Comments

REST Endpoint Testing With MockMvc

REST Endpoint Testing With MockMvc In this post I'm going to show you how to test a Spring MVC Rest endpoint without deploying your application to a server. In the past, full integration tests were the only meaningful way to test a Spring REST endpoint. This involved spinning up a test server like Tomcat or Jetty, deploying the application, calling the test endpoint, running some assertions and then terminating the server. While this is an effective way to test an endpoint, it isn't particularly fast. We're forced to wait while the entire application is stood up, just to test a single endpoint. An alternative approach [...]

By |2019-02-11T07:31:42+00:00May 25th, 2017|REST, Spring Boot, Testing|0 Comments

An Introduction to Wiremock

An Introduction to Wiremock This post provides a brief introduction to Wiremock, showing how it can be used to to quickly and easily mock remote API calls. We'll use Wiremock to write some integration tests for a simple Dropwizard app and show you how it can be put to use in a real world scenario. Why do I need to mock API calls? There are a number of scenarios where it makes sense to mock an external API rather than call a live service. The external API may still be in development and not yet available for integration. In this instance as long as a [...]

By |2019-02-18T07:10:56+00:00May 17th, 2016|Testing|0 Comments
Go to Top