JUnit Platform Suite API provides annotations and configuration options for creating test suites with the JUnit Platform, including test selection, filtering, and configuration capabilities for organizing and executing collections of tests
npx @tessl/cli install tessl/maven-org-junit-platform--junit-platform-suite-api@1.12.0JUnit Platform Suite API provides a comprehensive set of annotations for creating and configuring test suites on the JUnit Platform. It enables declarative test suite configuration with flexible test selection, advanced filtering, and extensive configuration capabilities for organizing and executing collections of tests across the JUnit Platform ecosystem.
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite-api</artifactId>
<version>1.12.2</version>
</dependency>import org.junit.platform.suite.api.Suite;
import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.SelectPackages;
import org.junit.platform.suite.api.IncludeTags;
import org.junit.platform.suite.api.ExcludeTags;import org.junit.platform.suite.api.*;
@Suite
@SelectPackages("com.example.tests")
@IncludeTags("integration")
@ExcludeTags("slow")
@SuiteDisplayName("Integration Test Suite")
public class IntegrationTestSuite {
// Suite configuration through annotations only
@BeforeSuite
static void setUp() {
// Optional setup before all tests in suite
System.out.println("Starting integration tests");
}
@AfterSuite
static void tearDown() {
// Optional cleanup after all tests in suite
System.out.println("Integration tests completed");
}
}The JUnit Platform Suite API is built around several key architectural components:
Central annotations for defining and configuring test suites with display names and failure behavior.
@Suite
public @interface Suite {
boolean failIfNoTests() default true;
}
@SuiteDisplayName("Custom Display Name")
public @interface SuiteDisplayName {
String value();
}Annotations for controlling execution flow with setup and teardown methods that run before and after all tests in a suite.
@BeforeSuite
static void setUp() { /* setup logic */ }
@AfterSuite
static void tearDown() { /* cleanup logic */ }Comprehensive test selection capabilities supporting classes, packages, methods, files, resources, directories, modules, and URIs with flexible selector syntax.
@SelectClasses({TestClass1.class, TestClass2.class})
@SelectPackages({"com.example.unit", "com.example.integration"})
@SelectMethod(type = MyTest.class, name = "testMethod")
@Select({"class:com.example.TestClass", "method:com.example.TestClass#testMethod"})Advanced filtering system for including and excluding tests based on engines, packages, tags, and class name patterns with support for complex tag expressions.
@IncludeEngines({"junit-jupiter", "junit-vintage"})
@ExcludeEngines("junit-platform-suite")
@IncludeTags({"unit", "integration"})
@ExcludeTags({"slow | flaky"})
@IncludeClassNamePatterns(".*Test")
@ExcludeClassNamePatterns(".*IT")Configuration parameter management with support for inline parameters, properties files, and inheritance control from parent discovery requests.
@ConfigurationParameter(key = "junit.jupiter.displayname.generator.default",
value = "org.junit.jupiter.api.DisplayNameGenerator$ReplaceUnderscores")
@ConfigurationParametersResource("/test-config.properties")
@DisableParentConfigurationParameters// Container annotations for repeatable annotations
public @interface Selects {
Select[] value();
}
public @interface SelectFiles {
SelectFile[] value();
}
public @interface SelectClasspathResources {
SelectClasspathResource[] value();
}
public @interface SelectMethods {
SelectMethod[] value();
}
public @interface ConfigurationParameters {
ConfigurationParameter[] value();
}
public @interface ConfigurationParametersResources {
ConfigurationParametersResource[] value();
}
// Deprecated annotation
@Deprecated
@API(status = DEPRECATED, since = "1.8")
public @interface UseTechnicalNames {
}