Category: JUnit

A Spring Boot RESTful service is typically divided into three layers:  Repository, Service, and Controller. This layering helps to segregate the RESTful application responsibilities and enabling loose coupling between the objects. When you develop a layered RESTful application, you will also need to test the different layers. In this post, I will discuss testing Spring […]Continue reading

So your JUnit 5 tests are not running under Maven? You have JUnit 5 Tests which run fine from your IDE, but fail to run under Maven? Your test output looks like this: [INFO] – – ————————————————— [INFO] T E S T S [INFO] – – ————————————————— [INFO] [INFO] Results: [INFO] [INFO] Tests run: 0, […]Continue reading

I have met many developers who refer to tests as “Unit Tests” when they are actually integration tests. In service layers, I’ve seen tests referred to as unit tests, but written with dependencies on the actual service, such as a database, web service, or some message server. Those are part of integration testing. Even if […]Continue reading

Unit tests should be small tests (atomic), lightweight, and fast. However, an object under test might have dependencies on other objects. It might need to interact with a database, communicate with a mail server, or talk to a web service or a message queue. All these services might not be available during unit testing. Even […]Continue reading

In the first part of the series on unit testing with JUnit, we looked at creating unit tests both using Maven and IntelliJ. In this post, we will look at some core unit testing concepts and apply those using JUnit constructs. We will learn about assertions, JUnit 4 annotations, and test suites. JUnit Assertions Assertions, […]Continue reading

Unit testing is the first level of testing software where you write test code that executes a specific functionality in the code to be tested. In most cases, you as a programmer are responsible to deliver unit tested code. The objective is to check if the unit of the software, for example a public method […]Continue reading

You will find a greater need for Integration tests as your testing requirements become more complex when you’re supporting enterprise application development using the Spring Framework. Sometimes, allowing Spring to manage the beans makes your testing easier, sometimes you want to test parts of your Spring Configuration, sometimes you’ll need to wire in a Mock component for […]Continue reading