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
—
Central annotations for defining and configuring test suites with display names and failure behavior control.
The primary annotation that marks a class as a test suite on the JUnit Platform.
/**
* Marks a class as a test suite on the JUnit Platform.
* Selector and filter annotations control suite contents.
* Configuration annotations provide additional parameters.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Inherited
@Documented
@API(status = STABLE, since = "1.10")
@Testable
public @interface Suite {
/**
* Fail suite if no tests were discovered.
* @return true to fail when no tests found, false to allow empty suites
* @since 1.9
*/
@API(status = STABLE, since = "1.11")
boolean failIfNoTests() default true;
}Usage Examples:
// Basic suite - fails if no tests found
@Suite
@SelectPackages("com.example.tests")
public class BasicTestSuite {
}
// Suite that allows empty results
@Suite(failIfNoTests = false)
@SelectTags("optional")
public class OptionalTestSuite {
}
// Complex suite with multiple selectors and filters
@Suite
@SelectClasses({UnitTests.class, IntegrationTests.class})
@IncludeTags("smoke")
@ExcludeTags("slow")
@ConfigurationParameter(key = "parallel.execution", value = "true")
public class SmokeTestSuite {
}Declares a custom display name for test suite execution in IDEs and build tools.
/**
* Declares a custom display name for test suite execution.
* Display names are used for test reporting and may contain spaces,
* special characters, and emoji.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Documented
@API(status = MAINTAINED, since = "1.1")
public @interface SuiteDisplayName {
/**
* The custom display name for the suite.
* @return custom display name; never blank or consisting solely of whitespace
*/
String value();
}Usage Examples:
@Suite
@SuiteDisplayName("🧪 Unit Test Suite")
@SelectPackages("com.example.unit")
public class UnitTestSuite {
}
@Suite
@SuiteDisplayName("Integration Tests - Database Layer")
@SelectClasses({DatabaseIntegrationTest.class, RepositoryTest.class})
public class DatabaseIntegrationSuite {
}
@Suite
@SuiteDisplayName("Performance & Load Testing")
@IncludeTags("performance")
public class PerformanceTestSuite {
}@IncludeClassNamePatterns is not present, the default include pattern ^(Test.*|.+[.$]Test.*|.*Tests?)$ is used@DisableParentConfigurationParameters to use only explicitly configured parametersSpecifies that technical names should be used instead of display names for test reporting.
/**
* Specifies that technical names should be used instead of display names.
* @deprecated since 1.8, in favor of @Suite support provided by
* junit-platform-suite-engine module; to be removed in JUnit Platform 2.0
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Documented
@API(status = DEPRECATED, since = "1.8")
@Deprecated
public @interface UseTechnicalNames {
}Migration Path:
// DEPRECATED - Don't use this
@RunWith(JUnitPlatform.class)
@UseTechnicalNames
@SelectPackages("com.example")
public class OldStyleSuite {
}
// RECOMMENDED - Use @Suite instead
@Suite
@SelectPackages("com.example")
public class ModernSuite {
}Important Notes:
@RunWith(JUnitPlatform.class) in JUnit 4 environments@Suite annotation provides equivalent functionality with better integrationfailIfNoTests() = true (default), suites will fail if no tests are discoveredInstall with Tessl CLI
npx tessl i tessl/maven-org-junit-platform--junit-platform-suite-api