Skip to content

Commit

Permalink
Document @MethodSource as use case for @TestInstance per-class li…
Browse files Browse the repository at this point in the history
…fecycle

This commit documents another use case for TestInstace.PER_CLASS in Kotlin,
namely, using a regular simple class method as a factory method for @MethodSource
(which is used for parameterized tests).

Closes: #3219
  • Loading branch information
mahozad committed Apr 2, 2023
1 parent e188b1e commit a5b642b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions documentation/src/docs/asciidoc/user-guide/writing-tests.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -751,8 +751,8 @@ NOTE: Beginning with Java 16, `@BeforeAll` and `@AfterAll` methods can be declar
`static` in `@Nested` test classes.

If you are authoring tests using the Kotlin programming language, you may also find it
easier to implement `@BeforeAll` and `@AfterAll` methods by switching to the "per-class"
test instance lifecycle mode.
easier to implement `@BeforeAll` and `@AfterAll` methods and also factory methods for
`@MethodSource` by switching to the "per-class" test instance lifecycle mode.

[[writing-tests-test-instance-lifecycle-changing-default]]
==== Changing the Default Test Instance Lifecycle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
* <li>Declaration of {@code @BeforeAll} and {@code @AfterAll} on interface
* {@code default} methods.</li>
* <li>Simplified declaration of non-static {@code @BeforeAll} and {@code @AfterAll}
* methods in test classes implemented with the Kotlin programming language.</li>
* methods and also factory methods for {@code @MethodSource} in test classes
* implemented with the Kotlin programming language.</li>
* </ul>
*
* <p>{@code @TestInstance} may also be used as a meta-annotation in order to
Expand Down

0 comments on commit a5b642b

Please sign in to comment.