Skip to content

Commit adadb70

Browse files
committed
Add a comment about extensions.
1 parent a956fb7 commit adadb70

1 file changed

Lines changed: 33 additions & 25 deletions

File tree

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
# Migration notes: features removed or replaced by junit5 functionality
22

3-
The following features of junit4-compatible `RandomizedRunner` have been
3+
The following features of junit4-compatible `RandomizedRunner` have been
44
removed or replaced by built-in functionality in junit5.
55

66
## Parameterized tests (`@ParametersFactory`)
77

88
* This feature is already part of JUnit5: use `@ParameterizedClass`, `@ParameterizedTest`
9-
or any other way to create dynamic tests that JUnit5 offers.
9+
or any other way to create dynamic tests that JUnit5 offers.
1010

1111
## Test groups and test filtering
1212

1313
* This feature is already part of JUnit5 in the
14-
form of[`@Tag` annotations](https://docs.junit.org/6.0.3/writing-tests/tagging-and-filtering.html).
14+
form of[`@Tag` annotations](https://docs.junit.org/6.0.3/writing-tests/tagging-and-filtering.html).
1515

1616
* Direct use of `tests.filter` and `tests.[group-name]` properties
17-
is not as straightforward as it was with `RandomizedRunner`. These properties
18-
need to be converted and passed to JUnit Jupiter using your build system's
19-
facilities: system properties alone won't have any effect. Here is
20-
an [example for gradle](https://docs.gradle.org/current/userguide/java_testing.html#test_grouping).
21-
17+
is not as straightforward as it was with `RandomizedRunner`. These properties
18+
need to be converted and passed to JUnit Jupiter using your build system's
19+
facilities: system properties alone won't have any effect. Here is
20+
an [example for gradle](https://docs.gradle.org/current/userguide/java_testing.html#test_grouping).
21+
2222
## Custom test case order (`@TestCaseOrdering`)
2323

2424
* This feature is already part of JUnit5 (`@TestMethodOrder`). However,
25-
It is technically not possible to write a reorderer that will use the root
26-
seed value to reorder methods consistently (because method orderers
27-
are run in discovery phase and execution contexts are not available then).
25+
It is technically not possible to write a reorderer that will use the root
26+
seed value to reorder methods consistently (because method orderers
27+
are run in discovery phase and execution contexts are not available then).
2828

2929
## Test instance creation control (`@TestCaseInstanceProvider`).
3030

@@ -37,26 +37,34 @@ are run in discovery phase and execution contexts are not available then).
3737
## Custom test-method providers (`@TestMethodProviders()`)
3838

3939
* JUnit5/ Jupiter offers many ways to discover tests dynamically. `@TestFactory`
40-
methods, templates, etc. While there is no one-to-one replacement, it should
41-
be possible to reimplement custom test providers with some minor refactorings.
42-
For example, if a `TestMethodProvider` was including all `test*` methods (JUnit3-style),
43-
you could write a `@TestFactory` in a common superclass and then just extend it. This
44-
test factory would something like this:
40+
methods, templates, etc. While there is no one-to-one replacement, it should
41+
be possible to reimplement custom test providers with some minor refactorings.
42+
For example, if a `TestMethodProvider` was including all `test*` methods (JUnit3-style),
43+
you could write a `@TestFactory` in a common superclass and then just extend it. This
44+
test factory would something like this:
45+
4546
```java
47+
4648
@TestFactory
4749
Stream<DynamicTest> includeTestMethodsWithNoAnnotations() {
4850
return Arrays.stream(getClass().getDeclaredMethods())
49-
.filter(m -> m.getName().startsWith("test")
50-
&& m.getParameterCount() == 0
51-
&& !Modifier.isStatic(m.getModifiers()))
52-
.map(m -> DynamicTest.dynamicTest(m.getName(), () -> {
53-
m.invoke(this);
54-
}));
51+
.filter(m -> m.getName().startsWith("test")
52+
&& m.getParameterCount() == 0
53+
&& !Modifier.isStatic(m.getModifiers()))
54+
.map(m -> DynamicTest.dynamicTest(m.getName(), () -> {
55+
m.invoke(this);
56+
}));
5557
}
5658
```
5759

5860
## Repeating tests with @Repeat
5961

60-
* Use standard JUnit5 test repetition facilities (like test templates, or `@RepeatedTest`
61-
annotation). To repeat the same test with a constant seed, `@FixSeed` at class or test level.
62-
If the seed is not fixed, it will be different for each test repetition by default.
62+
* Use standard JUnit5 test repetition facilities (like test templates, or `@RepeatedTest`
63+
annotation). To repeat the same test with a constant seed, `@FixSeed` at class or test level.
64+
If the seed is not fixed, it will be different for each test repetition by default.
65+
66+
## Multiple extensions instead of a single `RandomizedRunner`
67+
68+
* The `RandomizedRunner` combined multiple features in one class. This has been replaced by multiple
69+
extensions, which can be used independently. So `@Randomized` and `@DetectThreadLeaks` can be used
70+
completely independently of each other, for example.

0 commit comments

Comments
 (0)