Skip to content

Introduce junit-platform-suite-engine #2416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 43 commits into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
153b348
Implement junit-platform-suite-engine
mpkorstanje Dec 27, 2020
dd009ac
Apply review comments
mpkorstanje Jan 2, 2021
c7ad80f
Pass parentId along with discovery selection
mpkorstanje Jan 3, 2021
a82d550
Document the junit platform suite engine
mpkorstanje Jan 10, 2021
e21db43
Use more distance for cross package connections
mpkorstanje Jan 10, 2021
30379d7
Explain that test descriptors in the discovery result can be used as …
mpkorstanje Jan 16, 2021
9a15714
Reference correct group id in java doc
mpkorstanje Jan 16, 2021
d5d816d
Spotless
mpkorstanje Jan 17, 2021
354a47b
Merge remote-tracking branch 'origin/main' into junit-platform-suite-…
mpkorstanje Jan 30, 2021
c9e76fb
Consistently use fqn package names in @API(consumer) field
mpkorstanje Jan 30, 2021
3662638
Fix warnings on OpenJDK 17.
mpkorstanje Jan 30, 2021
1a6c97c
Move selector variations to DiscoverySelectors
mpkorstanje Jan 30, 2021
757977e
Reduce repetition
mpkorstanje Jan 30, 2021
f9a1f7b
Untangle SuiteDiscoveryRequestBuilder from LauncherDiscoveryRequestBu…
mpkorstanje Jan 30, 2021
bb86ebe
Use standard include patterns when IncludeClassNamePatterns is omitted
mpkorstanje Jan 30, 2021
f0cb4e2
Reuse SuiteLauncherDiscoveryRequestBuilder through duplication
mpkorstanje Jan 30, 2021
2a8d843
Remove duplication from suite-api-documentation
mpkorstanje Jan 30, 2021
9113788
Extract SuiteLauncherDiscoveryRequestBuilder to junit-platform-suite-…
mpkorstanje Jan 30, 2021
fabc3a3
Add junit-platform-suite-commons to dependency diagram
mpkorstanje Jan 30, 2021
5500c67
Clean up accessors
mpkorstanje Jan 30, 2021
32fe7e4
Clean up naming
mpkorstanje Jan 30, 2021
0d9f9d8
Update dependency list in docs
mpkorstanje Jan 30, 2021
e02608b
Support meta annotations
mpkorstanje Jan 30, 2021
f11f18e
Fix update documentation check
mpkorstanje Jan 30, 2021
aa7befa
Nits
mpkorstanje Jan 30, 2021
f4f4b0d
Nits
mpkorstanje Jan 31, 2021
5f7328a
Use delegation to keep purpose of suite request builder clear
mpkorstanje Jan 31, 2021
c59900f
Add test for meta-annotations
mpkorstanje Feb 6, 2021
a0e92f0
Fix java doc
mpkorstanje Feb 6, 2021
659f71c
Fix release notes
mpkorstanje Feb 6, 2021
dbe8cb0
Nits
mpkorstanje Feb 6, 2021
89dc3d5
Keep apiguardian as a transitive dependency
mpkorstanje Feb 6, 2021
10cfe8d
Merge remote-tracking branch 'origin/main' into junit-platform-suite-…
mpkorstanje Feb 6, 2021
2d1b7d1
Update junit-platform-suite-api/src/main/java/org/junit/platform/suit…
mpkorstanje Feb 7, 2021
7749b90
Update junit-platform-launcher/src/main/java/org/junit/platform/launc…
mpkorstanje Feb 7, 2021
01a611a
Update junit-platform-engine/src/main/java/org/junit/platform/engine/…
mpkorstanje Feb 7, 2021
8723325
Update documentation/src/docs/asciidoc/release-notes/release-notes-5.…
mpkorstanje Feb 7, 2021
da654f2
Update junit-platform-suite-engine/src/main/java/org/junit/platform/s…
mpkorstanje Feb 7, 2021
4ade1c4
Rename Configuration to ConfigurationParameter
mpkorstanje Feb 7, 2021
94e47a2
Only discover test in suit for engines direct descendents
mpkorstanje Feb 7, 2021
a7bb955
Delay prune until after suits have been discovered
mpkorstanje Feb 7, 2021
6b4a1f3
Add note about aggregator
mpkorstanje Feb 7, 2021
b9911f6
Use note styling
mpkorstanje Feb 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ val platformProjects by extra(listOf(
project(":junit-platform-launcher"),
project(":junit-platform-reporting"),
project(":junit-platform-runner"),
project(":junit-platform-suite"),
project(":junit-platform-suite-api"),
project(":junit-platform-suite-commons"),
project(":junit-platform-suite-engine"),
project(":junit-platform-testkit")
))

Expand Down Expand Up @@ -76,6 +79,8 @@ val jacocoTestProjects = listOf(
project(":junit-jupiter-migrationsupport"),
project(":junit-jupiter-params"),
project(":junit-platform-runner"),
project(":junit-platform-suite-commons"),
project(":junit-platform-suite-engine"),
project(":junit-vintage-engine"),
project(":platform-tests")
)
Expand Down
1 change: 1 addition & 0 deletions documentation/documentation.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ dependencies {
testImplementation(project(":junit-jupiter-migrationsupport"))
testImplementation(project(":junit-platform-console"))
testImplementation(project(":junit-platform-runner"))
testImplementation(project(":junit-platform-suite"))
testImplementation(project(":junit-platform-testkit"))
testImplementation("org.jetbrains.kotlin:kotlin-stdlib")

Expand Down
3 changes: 2 additions & 1 deletion documentation/src/docs/asciidoc/link-attributes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ endif::[]
:LegacyXmlReportGeneratingListener: {javadoc-root}/org.junit.platform.reporting/org/junit/platform/reporting/legacy/xml/LegacyXmlReportGeneratingListener.html[LegacyXmlReportGeneratingListener]
// Platform Runner
:JUnitPlatform-Runner: {javadoc-root}/org.junit.platform.runnner/org/junit/platform/runner/JUnitPlatform.html[JUnitPlatform]
// Platform Suite API
// Platform Suite
:suite-api-package: {javadoc-root}/org.junit.platform.suite.api/org/junit/platform/suite/api/package-summary.html[org.junit.platform.suite.api]
:junit-platform-suite-engine {javadoc-root}/org.junit.platform.suite.engine/org/junit/platform/suite/engine/package-summary.html[junit-platform-suite-engine]
// Platform Test Kit
:testkit-engine-package: {javadoc-root}/org.junit.platform.testkit/org/junit/platform/testkit/engine/package-summary.html[org.junit.platform.testkit.engine]
:EngineExecutionResults: {javadoc-root}/org.junit.platform.testkit/org/junit/platform/testkit/engine/EngineExecutionResults.html[EngineExecutionResults]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ on GitHub.
`LauncherSession` in order to allow for executing global setup and teardown code exactly
once via the new `LauncherSessionListener` interface that can be registered via Java’s
`{ServiceLoader}` mechanism.

* New `junit-platform-suite-engine` to execute declarative test suites using the JUnit
Platform Launcher.
* Added additional selectors to the `junit-platform-suite-api`

[[release-notes-5.8.0-M1-junit-jupiter]]
=== JUnit Jupiter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

include::launcher-api.adoc[]

include::junit-platform-suite-engine.adoc[]

include::testkit.adoc[]

////
Expand Down
41 changes: 29 additions & 12 deletions documentation/src/docs/asciidoc/user-guide/appendix.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,17 @@ artifacts are deployed to Sonatype's {snapshot-repo}[snapshots repository] under
`junit-platform-runner`::
Runner for executing tests and test suites on the JUnit Platform in a JUnit 4
environment. See <<running-tests-junit-platform-runner>> for details.
`junit-platform-suite`::
JUnit Platform Suite artifact that transitively pulls in dependencies on
`junit-platform-suite-api`, `junit-platform-suite-engine` for simplified
dependency management in build tools such as Gradle and Maven.
`junit-platform-suite-api`::
Annotations for configuring test suites on the JUnit Platform. Supported by the
<<running-tests-junit-platform-runner,JUnitPlatform runner>> and possibly by
third-party `TestEngine` implementations.
<<junit-platform-suite-engine,JUnit Platform Suite Engine>> and
<<running-tests-junit-platform-runner,JUnitPlatform runner>>.
Copy link
Contributor Author

@mpkorstanje mpkorstanje Jan 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've intentionally removed the reference to other test engines. Looking at the current implementations I don't think it is feasible for other test engines to replicate this functionality without using JUnits internals.

`junit-platform-suite-engine`::
Engine to execute suites on the JUnit Platform. See
<<junit-platform-suite-engine,JUnit Platform Suite Engine>> for details.
`junit-platform-testkit`::
Provides support for executing a test plan for a given `TestEngine` and then
accessing the results via a fluent API to verify the expected results.
Expand Down Expand Up @@ -148,7 +155,10 @@ package org.junit.platform {
[junit-platform-launcher] as launcher
[junit-platform-reporting] as reporting
[junit-platform-runner] as runner
[junit-platform-suite] as suite
[junit-platform-suite-api] as suite_api
[junit-platform-suite-commons] as suite_commons
[junit-platform-suite-engine] as suite_engine
[junit-platform-testkit] as testkit
}

Expand All @@ -173,15 +183,15 @@ jupiter ..> jupiter_api
jupiter ..> jupiter_params
jupiter ..> jupiter_engine

jupiter_api ..> opentest4j
jupiter_api ..> commons
jupiter_api ....> opentest4j
jupiter_api ...> commons

jupiter_engine ..> engine
jupiter_engine ...> engine
jupiter_engine ..> jupiter_api

jupiter_params ..> jupiter_api
jupiter_migration_support ..> jupiter_api
jupiter_migration_support ..> junit4
jupiter_migration_support ...> junit4

console ..> launcher
console ..> reporting
Expand All @@ -190,18 +200,25 @@ launcher ..> engine

jfr ..> launcher

engine ..> opentest4j
engine ....> opentest4j
engine ..> commons

reporting ..> launcher

runner ..> launcher
runner ..> suite_api
runner ..> junit4
runner ..> suite_commons
runner ...> junit4

testkit ..> opentest4j
suite ..> suite_api
suite ..> suite_engine

suite_engine ..> suite_commons

suite_commons ..> launcher
suite_commons ..> suite_api

testkit ....> opentest4j
testkit ..> launcher

vintage_engine ..> engine
vintage_engine ...> engine
vintage_engine ..> junit4
----
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[[junit-platform-suite-engine]]
=== JUnit Platform Suite Engine

The JUnit Platform supports declarative definition and execution of suites of tests from
_any_ test engine using the Junit Platform.

==== Setup

In addition to _at least one_ other test engine, you need the following artifacts and
their dependencies on the classpath. See <<dependency-metadata>> for details regarding
group IDs, artifact IDs, and versions.

===== Explicit Dependencies

* `junit-platform-suite-api` in _test_ scope
* `junit-platform-suite-engine` in _test runtime_ scope: implementation of the
`TestEngine` API for the declarative Junit Platform
Suites

===== Transitive Dependencies

* `junit-platform-suite-commons` in _test_ scope
* `junit-platform-launcher` in _test_ scope
* `junit-platform-engine` in _test_ scope
* `junit-platform-commons` in _test_ scope
* `opentest4j` in _test_ scope

==== Test Suite

By annotating a class with `@Suite` it is marked as a test suite on the JUnit Platform.
As seen in the following example, selector and filter annotations can then be used to
control the contents of the suite.

[source,java,indent=0]
----
include::{testDir}/example/SuiteDemo.java[tags=user_guide]
----

.Additional Configuration Options
NOTE: There are more configuration options for discovering and filtering tests than just
`@SelectPackages`. Please consult the Javadoc of the `{suite-api-package}` package for
further details.
3 changes: 3 additions & 0 deletions documentation/src/docs/asciidoc/user-guide/launcher-api.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ JUnit currently provides two `{TestEngine}` implementations.
* `{junit-jupiter-engine}`: The core of JUnit Jupiter.
* `{junit-vintage-engine}`: A thin layer on top of JUnit 4 to allow running _vintage_
tests with the launcher infrastructure.
* `{junit-platform-suite-engine}`: To execute declarative suites of tests with the
launcher infrastructure.


Third parties may also contribute their own `TestEngine` by implementing the interfaces
in the {junit-platform-engine} module and _registering_ their engine. By default, engine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@ You need the following artifacts and their dependencies on the classpath. See
===== Transitive Dependencies

* `junit-platform-suite-api` in _test_ scope
* `junit-platform-suite-commons` in _test_ scope
* `junit-platform-launcher` in _test_ scope
* `junit-platform-engine` in _test_ scope
* `junit-platform-commons` in _test_ scope
Expand Down
26 changes: 26 additions & 0 deletions documentation/src/test/java/example/SuiteDemo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright 2015-2021 the original author or authors.
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v2.0 which
* accompanies this distribution and is available at
*
* https://www.eclipse.org/legal/epl-v20.html
*/

package example;

//tag::user_guide[]
import org.junit.platform.suite.api.SelectPackages;
import org.junit.platform.suite.api.Suite;
import org.junit.platform.suite.api.SuiteDisplayName;

@Suite
@SuiteDisplayName("JUnit Platform Suite Demo")
@SelectPackages("example")
//end::user_guide[]
@org.junit.platform.suite.api.ExcludeTags("exclude")
//tag::user_guide[]
public class SuiteDemo {
}
//end::user_guide[]
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
org.junit.platform.reporting,
org.junit.platform.runner,
org.junit.platform.suite.api,
org.junit.platform.suite.engine,
org.junit.platform.testkit,
org.junit.vintage.engine;
exports org.junit.platform.commons.support;
Expand All @@ -46,6 +47,8 @@
org.junit.platform.reporting,
org.junit.platform.runner,
org.junit.platform.suite.api,
org.junit.platform.suite.commons,
org.junit.platform.suite.engine,
org.junit.platform.testkit,
org.junit.vintage.engine;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import static java.util.Collections.singletonList;
import static java.util.Collections.unmodifiableList;
import static org.apiguardian.api.API.Status.EXPERIMENTAL;
import static org.apiguardian.api.API.Status.STABLE;

import java.io.Serializable;
Expand Down Expand Up @@ -162,6 +163,24 @@ public final UniqueId append(Segment segment) {
return new UniqueId(this.uniqueIdFormat, baseSegments);
}

/**
* Construct a new {@code UniqueId} by appending a new {@link Segment}, based
* on the supplied {@code engineId}, to the end of this {@code UniqueId}.
*
* <p>This {@code UniqueId} will not be modified.
*
* <p>The engine ID will be stored in a {@link Segment} with
* {@link Segment#getType type} {@value ENGINE_SEGMENT_TYPE}.
*
* @param engineId the engine ID; never {@code null} or blank
*
* @since 1.8
*/
@API(status = EXPERIMENTAL, since = "1.8")
public UniqueId appendEngine(String engineId) {
return append(new Segment(ENGINE_SEGMENT_TYPE, engineId));
}

/**
* Determine if the supplied {@code UniqueId} is a prefix for this
* {@code UniqueId}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ public static ModuleSelector selectModule(String moduleName) {
*/
@API(status = EXPERIMENTAL, since = "1.1")
public static List<ModuleSelector> selectModules(Set<String> moduleNames) {
Preconditions.notNull(moduleNames, "moduleNames must not be null");
Preconditions.containsNoNullElements(moduleNames, "individual module name must not be null");
Preconditions.notNull(moduleNames, "Module names must not be null");
Preconditions.containsNoNullElements(moduleNames, "Individual module name must not be null");

// @formatter:off
return moduleNames.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class DefaultLauncher implements InternalLauncher {
Preconditions.notNull(postDiscoveryFilters, "PostDiscoveryFilter array must not be null");
Preconditions.containsNoNullElements(postDiscoveryFilters,
"PostDiscoveryFilter array must not contain null elements");
this.discoveryOrchestrator = new EngineDiscoveryOrchestrator(EngineIdValidator.validate(testEngines),
this.discoveryOrchestrator = new EngineDiscoveryOrchestrator(testEngines,
unmodifiableCollection(postDiscoveryFilters), launcherDiscoveryListenerRegistry);
}

Expand Down
Loading