Skip to content

Commit a5b642b

Browse files
authored
Document @MethodSource as use case for @TestInstance per-class lifecycle
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
1 parent e188b1e commit a5b642b

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,8 +751,8 @@ NOTE: Beginning with Java 16, `@BeforeAll` and `@AfterAll` methods can be declar
751751
`static` in `@Nested` test classes.
752752

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

757757
[[writing-tests-test-instance-lifecycle-changing-default]]
758758
==== Changing the Default Test Instance Lifecycle

junit-jupiter-api/src/main/java/org/junit/jupiter/api/TestInstance.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@
5151
* <li>Declaration of {@code @BeforeAll} and {@code @AfterAll} on interface
5252
* {@code default} methods.</li>
5353
* <li>Simplified declaration of non-static {@code @BeforeAll} and {@code @AfterAll}
54-
* methods in test classes implemented with the Kotlin programming language.</li>
54+
* methods and also factory methods for {@code @MethodSource} in test classes
55+
* implemented with the Kotlin programming language.</li>
5556
* </ul>
5657
*
5758
* <p>{@code @TestInstance} may also be used as a meta-annotation in order to

0 commit comments

Comments
 (0)