

Learn More about Java and Spring Boot, Secure REST APIs, and OIDCĬreate a Spring Boot App for Testing with JUnit 5įor this tutorial, the structure of the project is as shown below.


NOTE: For this post, I will be using Eclipse, as it is my preferred IDE. Spring Boot makes it even easier by allowing you to do much of the dependency injection with annotations instead of having to bother with a complicated applicationContext.xml file! The main advantage of using the Spring Framework is the ability to inject your dependencies, which makes it much easier to swap out implementations for various purposes, but not least of all for unit testing. Once we have built the API, we will walk through unit testing the code with JUnit 5 and review the coverage of our JUnit tests. This REST API will be secured with OAuth 2.0 and Okta. The application used for this post will be a basic REST API with endpoints to calculate a few things about a person’s birthday! There are three POST endpoints you will be able to use to determine either the day of the week, the astrological sign, or the Chinese Zodiac sign for a passed in birthday. A comprehensive suite of tools ensures that you can adequately test all areas of your application without the burden of writing your own test utilities. Using a modern framework ensures that you can keep up with the changes within your language and libraries. When building your tests, it is important to use a modern and comprehensive suite of tools. What good is your application if you don’t know that it will work under any condition? Adding a suite of tests builds confidence that your application can handle anything thrown at it. An application without testing is the proverbial Pandora’s Box. In this post, you’ll walk through how to build a simple Spring Boot application and test it with Junit 5.
