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

Filtering tests with Maven

As we already know, we need to use  maven-surefire-plugin in a Maven project to execute Jupiter test. Moreover, this plugin allows us to filter the test execution in several ways: filtering by JUnit 5 tags and also using the regular inclusion/exclusion support of maven-surefire-plugin.

In order to filter by tags, the properties includeTags and excludeTags of the maven-surefire-plugin configuration should be used. Let's see an example to demonstrate how. Consider the following tests contained in the same Maven project. On the one hand, all tests in this class are tagged with the  functional word.

package io.github.bonigarcia;import org.junit.jupiter.api.Tag;import org.junit.jupiter.api.Test;@Tag("functional")class ...

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