AI Features

Test Templates

Let's learn how to use test templates in JUnit 5.

We discussed repeated tests and parameterized tests in previous chapters. Methods annotated with @RepeatedTest and @ParameterizedTest aren’t the actual executed tests, but templates for other tests. JUnit 5 has a specific annotation, org.junit.jupiter.api.TestTemplate, that makes a test method a test template.

Creating test templates

To create test ...