Skip to content

Commit b9ab2bf

Browse files
committed
Document that static member classes are valid test classes
Issue: #1378
1 parent c7064e9 commit b9ab2bf

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

documentation/src/docs/asciidoc/user-guide/writing-tests.adoc

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,15 @@ named `@Fast` as follows. `@Fast` can then be used as a drop-in replacement for
6060
include::{testDir}/example/Fast.java[tags=user_guide]
6161
----
6262

63-
[[writing-tests-standard]]
64-
=== Standard Test Class
63+
[[writing-tests-classes-and-methods]]
64+
=== Test Classes and Methods
65+
66+
A _test method_ is any instance method that is directly or meta-annotated with `@Test`,
67+
`@RepeatedTest`, `@ParameterizedTest`, `@TestFactory`, or `@TestTemplate`. A _test class_
68+
is any top level or static member class that contains at least one test method.
6569

6670
[source,java,indent=0]
67-
.A standard test case
71+
.A standard test class
6872
----
6973
include::{testDir}/example/StandardTests.java[tags=user_guide]
7074
----
@@ -331,11 +335,11 @@ include::{testDir}/example/TaggingDemo.java[tags=user_guide]
331335

332336
In order to allow individual test methods to be executed in isolation and to avoid
333337
unexpected side effects due to mutable test instance state, JUnit creates a new instance
334-
of each test class before executing each _test_ method (see note below for what qualifies
335-
as a _test_ method). This "per-method" test instance lifecycle is the default behavior in
336-
JUnit Jupiter and is analogous to all previous versions of JUnit.
338+
of each test class before executing each _test method_ (see
339+
<<writing-tests-classes-and-methods>>). This "per-method" test instance lifecycle is the
340+
default behavior in JUnit Jupiter and is analogous to all previous versions of JUnit.
337341

338-
NOTE: Please note that the test class will still be instantiated if a given _test_ method
342+
NOTE: Please note that the test class will still be instantiated if a given _test method_
339343
is _disabled_ via a <<writing-tests-conditional-execution,condition>> (e.g., `@Disabled`,
340344
`@DisabledOnOs`, etc.) even when the "per-method" test instance lifecycle mode is active.
341345

@@ -355,9 +359,6 @@ If you are authoring tests using the Kotlin programming language, you may also f
355359
easier to implement `@BeforeAll` and `@AfterAll` methods by switching to the "per-class"
356360
test instance lifecycle mode.
357361

358-
NOTE: In the context of test instance lifecycle a _test_ method is any method annotated
359-
with `@Test`, `@RepeatedTest`, `@ParameterizedTest`, `@TestFactory`, or `@TestTemplate`.
360-
361362
[[writing-tests-test-instance-lifecycle-changing-default]]
362363
==== Changing the Default Test Instance Lifecycle
363364

0 commit comments

Comments
 (0)