xref: /aosp_15_r20/external/TestParameterInjector/CHANGELOG.md (revision 0a615120fe93b5def6ccfd1a41a03fb032dc2074)
1## 1.18
2
3- Made some internal JUnit4 methods of `TestParameterInjector` public:
4
5  - `computeTestMethods()`
6  - `methodBlock()`
7  - `methodInvoker()`
8
9  These allow any client to combine `TestParameterInjector` with another JUnit4
10  runner by manually creating a `TestParameterInjector` instance and calling
11  these methods from the combined JUnit4 runner.
12
13## 1.17
14
15- Added support for parsing `java.time.Duration` from a string. Example:
16
17```
18@Test
19public void myTest(@TestParameter({"1d", "2h20min", "10.5ms"}) Duration duration){...}
20```
21
22## 1.16
23
24- Deprecated [`TestParameter.TestParameterValuesProvider`](
25  https://google.github.io/TestParameterInjector/docs/latest/com/google/testing/junit/testparameterinjector/TestParameter.TestParameterValuesProvider.html)
26  in favor of its newer version [`TestParameterValuesProvider`](
27  https://google.github.io/TestParameterInjector/docs/latest/com/google/testing/junit/testparameterinjector/TestParameterValuesProvider.html).
28- Added support for repeated annotations to [`TestParameterValuesProvider.Context`](
29  https://google.github.io/TestParameterInjector/docs/latest/com/google/testing/junit/testparameterinjector/TestParameterValuesProvider.Context.html)
30- Converting incorrectly YAML-parsed booleans back to their enum values when possible
31- Support enum aliases (defined as static fields on the enum), and in particular
32  Protocol Buffer enum aliases
33- When generating test names for enum values, the enum name is used instead of
34  its `toString()` method.
35
36## 1.15
37
38- Add context aware version of [`TestParameterValuesProvider`](
39  https://google.github.io/TestParameterInjector/docs/latest/com/google/testing/junit/testparameterinjector/TestParameterValuesProvider.html).
40  It is the same as the old [`TestParameter.TestParameterValuesProvider`](
41  https://google.github.io/TestParameterInjector/docs/latest/com/google/testing/junit/testparameterinjector/TestParameter.TestParameterValuesProvider.html),
42  except that `provideValues()` was changed to `provideValues(Context)` where
43  [`Context`](
44  https://google.github.io/TestParameterInjector/docs/latest/com/google/testing/junit/testparameterinjector/TestParameterValuesProvider.Context.html)
45  contains the test class and the other annotations. This allows for more generic
46  providers that take into account custom annotations with extra data, or the
47  implementation of abstract methods on a base test class.
48
49  Example usage:
50
51```java
52import com.google.testing.junit.testparameterinjector.TestParameterValuesProvider;
53
54private static final class MyProvider extends TestParameterValuesProvider {
55  @Override
56  public List<?> provideValues(Context context) throws Exception {
57    var testInstance = context.testClass().getDeclaredConstructor().newInstance();
58    var fooList = ((MyBaseTestClass) testInstance).getFooList();
59    // ...
60
61    // OR
62
63    var fooList = context.getOtherAnnotation(MyCustomAnnotation.class).fooList();
64    // ...
65  }
66}
67```
68
69- Fixed some theoretical non-determinism that could arise from Java reflection
70  methods
71
72## 1.14
73
74- Fixed multiple constructors error when this library is used with Powermock.
75  See https://github.com/google/TestParameterInjector/issues/40.
76
77## 1.13
78
79- Add support for setting a custom name for a `@TestParameter` value given via a provider:
80
81```java
82private static final class FruitProvider implements TestParameterValuesProvider {
83  @Override
84  public List<?> provideValues() {
85    return ImmutableList.of(
86        value(new Apple()).withName("apple"),
87        value(new Banana()).withName("banana"));
88  }
89}
90```
91
92- Add support for `BigInteger` and `UnsignedLong`
93- JUnit4: Fix for interrupted test cases causing random failures with thread
94  reuse (porting [the earlier fix in
95  JUnit4](https://github.com/junit-team/junit4/issues/1365))
96
97## 1.12
98
99- Tweak to the test name generation: Show the parameter name if its value is potentially
100  ambiguous (e.g. null, "" or "123").
101- Made `TestParametersValues.name()` optional. If missing, a name will be generated.
102
103## 1.11
104
105- Replaced deprecated call to org.yaml.snakeyaml.constructor.SafeConstructor
106
107## 1.10
108
109- Removed dependency on `protobuf-javalite` (see
110  [issue #24](https://github.com/google/TestParameterInjector/issues/24))
111
112## 1.9
113
114- Bugfix: Support explicit ordering by the JUnit4 `@Rule`. For example: `@Rule(ordering=3)`.
115- Potential test name change: Test names are no longer dependent on the locale of the machine
116  running it (e.g. doubles with integer values are always formatted with a trailing `.0`)
117
118## 1.8
119
120- Add support for JUnit5 (Jupiter)
121
122## 1.7
123
124- Remove `TestParameterInjector` support for `org.junit.runners.Parameterized`,
125  which was undocumented and thus unlikely to be used.
126
127## 1.6
128
129- Bugfixes
130- Better documentation
131
132## 1.5
133
134- `@TestParameters` can now also be used as a repeated annotation:
135
136```java
137// Newly added and recommended for new code
138@Test
139@TestParameters("{age: 17, expectIsAdult: false}")
140@TestParameters("{age: 22, expectIsAdult: true}")
141public void withRepeatedAnnotation(int age, boolean expectIsAdult){...}
142
143// The old way of using @TestParameters is still supported
144@Test
145@TestParameters({
146    "{age: 17, expectIsAdult: false}",
147    "{age: 22, expectIsAdult: true}",
148})
149public void withSingleAnnotation(int age, boolean expectIsAdult){...}
150```
151
152- `@TestParameters` supports setting a custom test name:
153
154```java
155@Test
156@TestParameters(customName = "teenager", value = "{age: 17, expectIsAdult: false}")
157@TestParameters(customName = "young adult", value = "{age: 22, expectIsAdult: true}")
158public void personIsAdult(int age, boolean expectIsAdult){...}
159```
160
161- Test names with very long parameter strings are abbreviated differentily: In
162  some cases, more characters are allowed.
163
164## 1.4
165
166- Bugfix: Run test methods declared in a base class (instead of throwing an
167  exception)
168- Test names with very long parameter strings are now abbreviated with a snippet
169  of the shortened parameter
170- Duplicate test names are given a suffix for deduplication
171- Replaced dependency on `protobuf-java` by a dependency on `protobuf-javalite`
172
173## 1.3
174
175- Treat 'null' as a magic string that results in a null value
176
177## 1.2
178
179- Don't use the parameter name if it's not explicitly provided by the compiler
180- Add support for older Android SDK versions by removing the dependency on
181  `j.l.r.Parameter`. The minimum Android SDK version is now 24.
182
183## 1.1
184
185- Add support for `ByteString` and `byte[]`
186