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