</>CodexBash
All articles
Java and Spring

Testing with JUnit

Write good tests in Java with JUnit 5: setting up with Maven or Gradle, test structure and assertions, AssertJ, lifecycle methods, parameterised tests, testing exceptions, nested and display names, mocking with Mockito, Spring Boot test slices, Testcontainers for real databases, and habits that keep tests valuable.

CodexBash, , 5 min read

Tests are what let you change code with confidence: refactor, upgrade a library or fix a bug without wondering what you broke. In Java, JUnit is the standard testing framework, and JUnit 5 (also called JUnit Jupiter) is the current generation, used by Spring Boot and virtually every modern project. This article covers writing tests with JUnit 5, making them expressive with AssertJ, isolating code with Mockito, testing Spring applications and real databases, and the habits that keep a test suite valuable rather than a burden.

Sign in to read the rest

The whole 5 minute article is free with an account, along with every problem, lesson and tutorial. No card.