From the course: Complete Guide To Java Testing with JUnit 5 & Mockito
Set up JUnit 5 in your Java application
From the course: Complete Guide To Java Testing with JUnit 5 & Mockito
Set up JUnit 5 in your Java application
- [Instructor] Let's set up Junit 5 in a Java application. To start, we'll open up our code in GitHub Codespaces. This sample application already has Maven set up for us. To add tests with JUnit, we'll need to add it as a dependency in our application. Maven lets us add dependencies in the POM file. This dependency includes the JUnit Jupiter API, which is essential for writing and executing JUnit 5 tests. To enable the Maven tool to execute these tests, we'll also configure the Maven Surefire Plugin in the same file. Our POM file is now all set up. To make sure this is synchronized with our application, let's run a Maven clean in the terminal. This command cleans the directory, removing any compiled sources, resources and test results. It ensures a clean build environment. We also have the Java Test Runner Extension already enabled. This is an extension specific to VS Code, and it allows us to run our tests directly in the editor. And with that, our environment is ready for us to write our first JUnit test.
Contents
-
-
-
-
Set up JUnit 5 in your Java application2m 24s
-
(Locked)
Write and run your first JUnit 5 test4m 11s
-
(Locked)
Assertions in JUnit 57m 56s
-
(Locked)
JUnit 5 test lifecycle1m 51s
-
(Locked)
JUnit 5 lifecycle hooks2m 49s
-
(Locked)
Testing exceptions in JUnit 52m 54s
-
(Locked)
Debug tests in JUnit 54m 30s
-
(Locked)
Best practices for writing tests in JUnit 52m 17s
-
(Locked)
Challenge: Write a JUnit 5 test for a temperature converter47s
-
(Locked)
Solution: Write a JUnit 5 Test for a Temperature Converter6m 33s
-
-
-
-
-
-
-
-