From the course: Complete Guide To Java Testing with JUnit 5 & Mockito
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Create a test coverage report with JaCoCo
From the course: Complete Guide To Java Testing with JUnit 5 & Mockito
Create a test coverage report with JaCoCo
- [Instructor] One way to ensure your code functions as intended is through comprehensive test coverage. In Java, one way to guarantee a test coverage percentage is with JaCoCo. JaCoCo stands for Java Code Coverage, and it's a plugin we seamlessly add to our Maven build configuration. Let's add it to this application. We'll go to our POM file and add a new plugin. The group ID will be org.jacoco. The artifact ID will be jacoco-maven-plugin, and the version will be 0.8.12. JaCoCo is a popular code coverage library for Java, and this plugin integrates it with Maven. Then we'll add an execution section. This will contain configurations that define when and how the plugin goals are executed during the build lifecycle. The prepare-agent goal sets up the JaCoCo Java Agent to collect coverage data during the test phase. This setup is necessary for JaCoCo to monitor the code coverage of your tests. We'll also add a second execution for the test phase. This goal generates the coverage report…
Contents
-
-
-
-
-
-
Introduction to parameterized tests in JUnit2m 4s
-
(Locked)
Parameterized tests with EnumSource in JUnit 53m 21s
-
(Locked)
Parameterized tests with ValueSource in JUnit 52m 20s
-
(Locked)
Parameterized tests with CsvSource in JUnit 53m 26s
-
(Locked)
Conditional test execution based on Java version and OS2m 12s
-
(Locked)
Conditional test execution based on environment variables2m 35s
-
(Locked)
Conditional test execution based on custom conditions1m 40s
-
(Locked)
Control test execution with @Order2m 37s
-
(Locked)
Create test suites in JUnit 53m 12s
-
(Locked)
Create a test coverage report with JaCoCo4m 9s
-
(Locked)
Ensure test coverage with JaCoCo5m 41s
-
(Locked)
Execute parallel tests in JUnit 52m 41s
-
(Locked)
Custom extensions in JUnit 54m 40s
-
(Locked)
Challenge: Write a test class for a email validator1m 57s
-
(Locked)
Solution: Write a test class for a email validator5m 32s
-
-
-
-
-
-