From d1cbcfb7f954a6a78e870d54f240341560741c45 Mon Sep 17 00:00:00 2001 From: Marc Philipp Date: Sat, 21 Apr 2018 15:00:29 +0200 Subject: [PATCH] Document that static member classes are valid test classes Issue: #1378 --- .../asciidoc/user-guide/writing-tests.adoc | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/documentation/src/docs/asciidoc/user-guide/writing-tests.adoc b/documentation/src/docs/asciidoc/user-guide/writing-tests.adoc index e4fc9b837f1d..e60f217c6715 100644 --- a/documentation/src/docs/asciidoc/user-guide/writing-tests.adoc +++ b/documentation/src/docs/asciidoc/user-guide/writing-tests.adoc @@ -60,11 +60,15 @@ named `@Fast` as follows. `@Fast` can then be used as a drop-in replacement for include::{testDir}/example/Fast.java[tags=user_guide] ---- -[[writing-tests-standard]] -=== Standard Test Class +[[writing-tests-classes-and-methods]] +=== Test Classes and Methods + +A _test method_ is any instance method that is directly or meta-annotated with `@Test`, +`@RepeatedTest`, `@ParameterizedTest`, `@TestFactory`, or `@TestTemplate`. A _test class_ +is any top level or static member class that contains at least one test method. [source,java,indent=0] -.A standard test case +.A standard test class ---- include::{testDir}/example/StandardTests.java[tags=user_guide] ---- @@ -331,11 +335,11 @@ include::{testDir}/example/TaggingDemo.java[tags=user_guide] In order to allow individual test methods to be executed in isolation and to avoid unexpected side effects due to mutable test instance state, JUnit creates a new instance -of each test class before executing each _test_ method (see note below for what qualifies -as a _test_ method). This "per-method" test instance lifecycle is the default behavior in -JUnit Jupiter and is analogous to all previous versions of JUnit. +of each test class before executing each _test method_ (see +<>). This "per-method" test instance lifecycle is the +default behavior in JUnit Jupiter and is analogous to all previous versions of JUnit. -NOTE: Please note that the test class will still be instantiated if a given _test_ method +NOTE: Please note that the test class will still be instantiated if a given _test method_ is _disabled_ via a <> (e.g., `@Disabled`, `@DisabledOnOs`, etc.) even when the "per-method" test instance lifecycle mode is active. @@ -355,9 +359,6 @@ If you are authoring tests using the Kotlin programming language, you may also f easier to implement `@BeforeAll` and `@AfterAll` methods by switching to the "per-class" test instance lifecycle mode. -NOTE: In the context of test instance lifecycle a _test_ method is any method annotated -with `@Test`, `@RepeatedTest`, `@ParameterizedTest`, `@TestFactory`, or `@TestTemplate`. - [[writing-tests-test-instance-lifecycle-changing-default]] ==== Changing the Default Test Instance Lifecycle