0

Spring Boot – How to unit test RESTful API URLs

This post demonstrates how to unit test RESTful API URLs using Spring Boot 1.5.10RELEASE. We basically just want to ensure the list of URLs still work and match what has been documented per specification.

Authenticate User – Controller

We have a simple controller that supposedly authenticates users. Notice we do not have the actual codes to perform the authentication. That’s fine!

When we test for only the URL, the implementation of a method does not matter.

Unit Test

Sample Output

Notice there is no text written from our controller.

Download the Codes

https://github.com/Turreta/Spring-Boot-How-to-unit-test-RESTful-API-URLs

Karl San Gabriel

Karl San Gabriel

Java and Enterprise Technologies Expert