Skip to content

Commit 16ff13b

Browse files
committed
Add note duplicate test execution with @suite
Users are surprised to see that their tests are executed twice[1]. This is the natural consequence of using a test engine to define a suite. We can at least let them know in the documentation. 1. #4327
1 parent 3fb4f96 commit 16ff13b

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

documentation/src/docs/asciidoc/user-guide/advanced-topics/junit-platform-suite-engine.adoc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[[junit-platform-suite-engine]]
22
=== JUnit Platform Suite Engine
33

4-
The JUnit Platform supports the declarative definition and execution of suites of tests
5-
from _any_ test engine using the JUnit Platform.
4+
The Suite Engine supports the declarative selection and execution of tests from
5+
_any_ test engine using the JUnit Platform.
66

77
[[junit-platform-suite-engine-setup]]
88
==== Setup
@@ -48,6 +48,13 @@ NOTE: There are numerous configuration options for discovering and filtering tes
4848
test suite. Please consult the Javadoc of the `{suite-api-package}` package for a full
4949
list of supported annotations and further details.
5050

51+
.Duplicate test execution
52+
NOTE: Tests in a suite are executed in addition to the tests executed by every other test
53+
engine, so it is possible to for the same test to be executed twice. A common solution is
54+
to use a naming pattern. Name all suites `*Suite` and all tests `*Test` and configure your
55+
build tool to only include the former. Alternatively, consider
56+
<<running-tests-tags, using tags>> to select specific groups of tests.
57+
5158
==== @BeforeSuite and @AfterSuite
5259

5360
`@BeforeSuite` and `@AfterSuite` annotations can be used on methods inside a

junit-platform-suite-api/src/main/java/org/junit/platform/suite/api/Suite.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* {@code @Suite} marks a class as a test suite on the JUnit Platform.
2727
*
2828
* <p>Selector and filter annotations are used to control the contents of the
29-
* suite. Additionally configuration can be passed to the suite via the
29+
* suite. Additionally, configuration can be passed to the suite via the
3030
* configuration annotations.
3131
*
3232
* <p>When the {@link IncludeClassNamePatterns @IncludeClassNamePatterns}
@@ -44,6 +44,12 @@
4444
* annotation disables the latter as a source of parameters so that only explicit
4545
* configuration parameters are taken into account.
4646
*
47+
* <p>Note: Tests in a suite are executed in addition to the tests executed by every
48+
* other test engine, so it is possible to for the same test to be executed twice. A
49+
* common solution is to use a naming pattern. Name all suites {@code *Suite} and all
50+
* tests {@code *Test} and configure your build tool to only include the former.
51+
* Alternatively, consider using tags to select specific groups of tests.
52+
*
4753
* @since 1.8
4854
* @see Select
4955
* @see SelectClasses

0 commit comments

Comments
 (0)