Integration testing on REST urls with Spring Boot

We are building a Spring Boot application with a REST interface and at some point we wanted to test our REST interface, and if possible, integrate this testing with our regular unit tests. One way of doing this, would be to @Autowire our REST controllers and call our endpoints using that. However, this won’t give full converage, since it will skip things like JSON deserialisation and global exception handling. So the ideal situation for us would be to start our application when the unit test start, and close it again, after the last unit test.
It just so happens that Spring Boot does this all for us with one annotation: @IntegrationTest.
Here is an example implementation of an abstract class you can use for your unit-tests which will automatically start the application prior to starting your unit tests, caching it, and close it again at the end.

Day two of the SpringOne 2GX in Washington.

It was a full day starting with breakfast and 5 one and a half hour long presentations followed by dinner and a keynote delivered by Adrian Colyer, CTO of SpringSource.

The keynote was on how application architecture has evolved over the last 10 years towards what it has become today. We started out with a static frontend client that communicated with a service layer, which in turn persisted to a database. Nowadays we have rich clients, multiple services in our service tier that in turn connect to services, websockets and/or other data sources.

Continue reading