
Meet your instructor John Thompson, founder of Spring Framework Guru, Speaker at Spring One, former Spring Source consultant
Welcome to the Testing Spring Boot course!
Complete the course to gain full benefits, fork and compare GitHub lesson branches, and join the Slack community for real-time collaboration.
Master the course's GitHub workflow by forking, cloning, and using branches to track lesson states, compare changes, and fetch updates from the original repository.
Introduction to testing software.
Explore why software testing matters, from unit tests to functional tests, and learn test coverage, fixtures, mocks, and BDD and TDD for clean, maintainable code.
See a very simple JUnit 5 unit test.
Overview of common testing frameworks for Java and Spring Boot. Includes: JUnit 4, JUnit 5, TestNG, Spock, Mockito, Selenium, and GEB.
Learn why having proper test coverage via JUnit tests is needed to realize the benefits of CI/CD for your Spring Boot applications.
Section overview for learning Test Driven Development using JUnit 5.
Learn about the original author of JUnit, Kent Beck, and his passion for Test Driven Development.
In this lesson, we review the development requirements for completing the TDD section of the course using JUnit 5.
Explore multi currency money calculations using test-driven development, implementing a dollar class to add currencies with exchange rates and multiply by shares, guided by a practical to-do list.
Explore degenerate objects and avoid mutating state by applying test-driven development cycles to refactor code toward immutable objects, ensuring tests go green with clean, reliable behavior.
Explore equality in test-driven development by implementing equals and hash code for a dollar value object, and write tests for equal and not-equal cases, including null handling.
Explore privacy in object-oriented design by making the amount property private to prevent external modification. Refactor tests to use the equals functionality, reinforcing defensive coding and preserving test reliability.
Explore test-driven development by implementing a Franc currency object, writing failing tests, and refactoring to remove duplication while verifying that five francs times two equals ten francs.
Refactor a Java money system by introducing a base money class, moving the amount field, and implementing a shared equals method for dollars and francs, with tests staying green.
Refactor the times method across dollar and franc into the money class to remove duplication, using test driven development to keep tests green and preserve currency behavior.
Refactor the money model by removing the dollar and franc subclasses and consolidating their duplication into the money class, use IntelliJ's safe delete to remove classes and streamline tests.
Implement a currency conversion workflow by modeling a Pair as a map key, adding equals and hashcode, and wiring a Bank to supply conversion rates for money.
Explore test-driven development on mixed currencies by implementing plus and times in Sum and Expression, fix a null pointer, and refactor to keep tests green.
Learn to run tests with coverage in IntelliJ, view coverage for classes, methods, and lines, and use the debugger, inspections, and refactorings to improve Java quality.
Conclude the test-driven development journey by starting with a simple, failing test and evolving it through refactoring to a quality, standard OOP implementation.
Overview of the Getting Started with JUnit 5 section of the course.
Overview of JUnit 5.
How to add the required dependencies for JUnit 5 to your Maven POM.
Simple "Hello World" example in JUnit 5.
See how to initialize properties using the JUnit @Before annotation.
Configure Gradle with JUnit 5 dependencies and a Surefire-like test runner, enable test logging and show standard streams, and run clean, build, and test tasks in IntelliJ.
Conclude getting started with JUnit 5 by comparing Maven and Gradle dependencies, running a hello world test, and reinforcing Maven and Gradle as primary Java build tools for enterprises.
Introduction to this section of the course, which is an introduction to JUnit 5.
In this lesson we review the code of a project we will use to write tests using JUnit 5.
Learn how JUnit 5 assertions work, from assertEquals and not null to grouped and dependent assertions using lambdas, plus leveraging failure messages, timeouts, and frameworks like AssertJ, Hamcrest, and Truth.
Learn to write JUnit assertions for a simple index controller in IntelliJ, using assertEquals and assertTrue with lazy lambda messages. Explore assertion API overloads and before-each setup.
Learn how to use JUnit grouped assertions with assertAll to run multiple lambda-based checks on a POJO, revealing clear, readable test output.
Learn how to use JUnit's @Disabled to skip tests, disable specific methods or entire classes, and document reasons, while understanding IntelliJ's handling of disabled tests.
Use JUnit's DisplayName annotation to assign meaningful names to tests, improving visibility in IDEs and reports, with support for descriptive text and even emojis.
Explore asserting timeouts with JUnit using assertTimeout and assertTimeout preemptively, with Duration.ofMills, distinguishing single-thread from multi-thread execution, and how to disable failing tests before check-in.
Explore JUnit assumptions and how they differ from assertions, using test aborted exceptions to conditionally run tests in environments like CI, causing tests to be ignored rather than failed.
Learn how to use the AssertJ library with JUnit in Spring Boot tests, setting up the core dependency in pom, and importing static assertThat for richer, clearer assertions.
Explore using hamcrest with JUnit, including adding the hamcrest-library dependency and importing assertThat with matchers. Learn about legacy hamcrest usage and how it coexists with JUnit and AssertJ.
Identify JUnit 5 features and that 80% of use cases rely on creating tests, display names, and assertions, with bite-size videos helping you reference functionality for the remaining 20%.
Introduction to the section of the course on advanced features of JUnit 5.
Learn how you can tag and filter JUnit tests.
Learn how to use JUnit nested tests.
JUnit 5 brings the capability to use Java interfaces for your unit tests
You can use Java default methods with your JUnit 5 tests.
See how to repeat JUnit tests multiple times.
JUnit 5 has the ability to inject dependencies into your tests.
Student assignment covering JUnit dependency injection.
Review of student assignment covering JUnit dependency injection.
Demonstrate configuring parameterized tests in JUnit with displayName and Value Source, using placeholders for displayName, index, and arguments to produce clear test names.
Read csv test data from the resources folder using CsvFileSource in JUnit 5, skipping the header and mapping state and values for Spring Boot tests.
Demystifies unit tests versus integration tests, shows how Maven detects integration tests by the IT suffix, and explains naming, setup, and basic organization for future Spring contexts and databases.
Explore how to use JUnit extensions with the ExtendWith annotation to hook into beforeTestExecution and afterTestExecution, demonstrated by a timing extension that logs test durations.
Explore the extensible design of JUnit 5, including parameterized tests and writing test extensions, and preview future extensions for Mockito and Spring within a plain vanilla Java focus.
Configure the Maven surefire report plugin to generate a project report website via the Maven site goal, upgrading the Maven site plugin to resolve class-not-found errors and display surefire reports.
Tag JUnit tests with the tag annotation and configure Maven Surefire to include or exclude groups using tag expressions, enabling controller and model test selections and profile-based runs.
Explore a Gradle-based Spring pet clinic project migrated from Maven, configured for Java 11 and JUnit 5, using the Gradle wrapper 4.10.2+, build.gradle settings, and test logging of standard streams.
learn to run junit tests from gradle using the gradle wrapper in IntelliJ, including clean and test tasks, and execute via the command line with gradlew or gradle.bat.
Learn how Gradle handles integration tests, noting no default integration test concept like Maven's surefire and failsafe, and how to configure an integrationTest task and source sets.
Explore Gradle JUnit test reports by viewing standard JUnit XML output and the generated HTML test summary, including durations, pass/fail status, and descriptions from display name annotations.
Convert remaining tests from junit to junit.jupiter.api and migrate the project to junit 5 using the spring extension and optimized imports.
Remove JUnit 4 from the Spring Boot project by excluding the junit artifact, exclude junit-vintage, migrate to JUnit 5 using Jupiter API, and reimport with Maven.
Migrate from JUnit 4 to JUnit 5 using the vintage engine and run existing JUnit 4 tests in the JUnit 5 engine, while previewing Mockito and Spring testing features.
Compare using the JUnit 5 Mockito extension with ExtendWith against beforeEach init mocks, and decide which technique you prefer for clean mock setup.
Inject mocks into the SpecialityService using Mockito with @ExtendWith, @Mock, and @InjectMocks, injecting a SpecialityRepository, and test the delete method with JUnit 5.
Learn how to verify mock interactions in Mockito by using verify with deleteById and control invocation counts with times, atLeastOnce, atMost, and never.
Create a unit test for deleteById in the vet service using Mockito, mock the VetRepository, inject mocks with @InjectMocks via MockitoExtension, and verify the interaction occurs once.
Conclude your Mockito fundamentals by mastering mocks, inject mocks, return values, and interaction verification as the core, day-to-day tools for fast, lightweight unit tests in Spring and Java.
Explore behavior driven development (BDD) as a behavior-focused approach to testing. Learn to apply given when then for organizing tests and using BDDMockito for mock verification.
Explore BDD with Mockito by converting a findById test to given and willReturn, contrasting with when/thenReturn and returning an Optional of Speciality.
Refactor a Mockito test to a bdd style using given when then, verify that findById is called once with anyLong, and ensure no further interactions.
Convert VisitSDJpaServiceTest to bdd style by adding given and then patterns and using Mockito bdd methods to practice behavior driven development over test driven development.
Explore behavior driven development with Mockito and its behavior driven API, a notable feature of the Mockito library. Evaluate personal preferences and how this addition can fit your testing toolkit.
In modern software development having proper automated test coverage is considered a best practice. In this course you will learn how to test Java and Spring Boot applications using highly popular open source tools.
You will see in the first section of this course, the software testing ecosystem is very diverse. JUnit and Mockito are two of the leading testing libraries for Java. JUnit provides the test execution context, while Mockito give you power mocking capabilities. Together these libraries can be used to write unit tests, integration tests, and functional tests. You will also learn why having proper test coverage is critical to supporting other popular agile practices such as Continuous Integration and Continuous Deployment (aka CI/CD).
Agile teams all over the world consider Test Driven Development (TDD) a critical technique for producing quality software. This course begins by using JUnit 5 to demonstrate how to use TDD to create a simple Java application, then again using TDD to evolve the application to a higher level of quality and functionality.
Next, the course takes you into a deep dive of the features and functionality of JUnit 5. You will learn how to write JUnit 5 unit tests for a Java web application.
The primary focus of this course is on the JUnit 5 release. There are some very notable differences between JUnit 4 and JUnit 5. This course contains a dedicated section showing you how to migrate your JUnit 4 tests to JUnit 5.
As your testing needs become more complex, you will need to mock dependent objects.
Not sure what a mock is? It's effectively a test double. An object created for unit testing.
Mockito is the most popular mocking library used by Java developers.
If you are writing Spring Framework applications, you're likely to be injecting dependent objects into your classes. You will learn how to use the robust mocking capabilities of Mockito to mock dependent objects in your unit tests.
The first 11 sections of the course focus heavily on unit testing with JUnit 5 and Mockito. This is to help you establish a strong unit testing foundation before we start testing Spring Boot applications.
You will have no doubts when it comes to testing Java classes using JUnit 5 and Mockito.
The Spring Framework itself has some very robust testing capabilities.
We start learning to test the Spring Framework by adding the Spring Framework Testing context to our tests.
This allows us to leverage the Spring Framework's Dependency Injection capabilities right in our tests.
Properly testing Spring MVC controllers can always be a little tricky. You need to test all the things you are expecting the Spring Framework to handle for you around calls to your controllers.
This is where Spring MVC Test steps in. You will see how you can use Spring MVC Test with JUnit 5 and Mockito to properly test your Spring MVC Controllers.
The course continues showing you how to use Spring Boot test splices to bring up a minimal Spring Boot configuration for the testing of a Spring MVC RESTful controller.
Another powerful Spring project is Spring MVC REST Docs. This is a project which allows you to generate API documentation from your Spring Mock MVC tests.
Inside this course you will learn:
JUnit 5
AssertJ
Hamcrest Matchers
Mockito 2
Test Driven Development (TDD)
Behavior Driven Development (BDD) with Mockito
Migrating to JUnit 5 from JUnit 4
Running JUnit 5 tests from Maven
Running JUnit 5 tests from Gradle
Use CircleCI with Maven for Continuous Integration Testing
Spring MVC Test
JsonPath
Wiremock
Spring MVC REST Docs
Course Extra - IntelliJ IDEA Ultimate
Students enrolling in the course can receive a free 120 day trial license to IntelliJ IDEA Ultimate! Get hands on experience using the Java IDE preferred by Spring Framework professionals!
Course Extra - Access to a Private Slack Community
You're not just enrolling in a course --> You are joining a community learning about testing Spring.
With your enrollment to the course, you can access an exclusive Slack community. Get help from the instructor and other Spring Framework Gurus from around the world - in real time! This community is only available to students enrolled in this course.
This is a very active Slack community with over 1,000 Spring Framework Gurus!
This is the largest online community of people learning Spring in the world.
With your enrollment, you can join this community of awesome gurus!
Source Code Access
All course source code is available in GitHub. When you enroll, refer to the lesson resources for links to GitHub.
Closed Captioning / Subtitles
Closed captioning in English is available for all course videos!
PDF Downloads
All keynote presentations are available for you to download as PDFs.
Lifetime Access
When you purchase this course, you will receive lifetime access! You can login anytime from anywhere to access the course content.
No Risk - Money Back Guarantee
You can buy this course with no risk. If you are unhappy with the course, for any reason, you can get a complete refund. The course has a 30 day Money Back Guarantee.
Enroll today and start learning about the latest tools and best practices for testing your Spring Boot applications!