O'Reilly logo

Mastering Software Testing with JUnit 5 by Boni García

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Test Launcher API

One of the goals of JUnit 5 is to make the interface between JUnit and its programmatic clients (build tools and IDEs) more powerful and stable. To that aim, the Test Launcher API has been implemented. This API is used by IDEs and build tools for discovering, filtering, and executing tests.

Looking closer at the details of this API, we find the class LauncherDiscoveryRequest, which exposes a fluent API to select the location of tests (for example classes, methods, or packages). This group of tests can be filtered, for example, using a match pattern:

import static org.junit.platform.engine.discovery.ClassNameFilter.includeClassNamePatterns;import static org.junit.platform.engine.discovery.DiscoverySelectors.selectClass;

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required