Category: JUnit

Parameterized tests in JUnit 5 enable you to run a test multiple times with different parameters. It helps the developers to save time in writing and executing the tests. We can write JUnit 5 parameterized tests just like regular JUnit 5 tests but have to use the @ParameterizedTest annotation instead. In a parameterized test, you […]Continue reading

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, Failures: 0, Errors: 0, […]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