diff options
author | Jens Nyman <jnyman@google.com> | 2024-01-17 10:12:54 +0000 |
---|---|---|
committer | Jens Nyman <jnyman@google.com> | 2024-01-17 10:12:54 +0000 |
commit | 25cf9ffd9ca74a49da627401f859e3f7c0c788d2 (patch) | |
tree | c1bd84808a0145d048d8a016eb95461466819d16 | |
parent | e312198862b27a3ca25772b230dae716e33dbca0 (diff) | |
download | TestParameterInjector-25cf9ffd9ca74a49da627401f859e3f7c0c788d2.tar.gz |
Update CHANGELOG with the new context aware values provider
https://github.com/google/TestParameterInjector/issues/44
-rw-r--r-- | CHANGELOG.md | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 535d387..da49481 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,39 @@ +## 1.15 + +- Add context aware version of [`TestParameterValuesProvider`]( + https://google.github.io/TestParameterInjector/docs/latest/com/google/testing/junit/testparameterinjector/TestParameterValuesProvider.html). + It is the same as the old [`TestParameter.TestParameterValuesProvider`]( + https://google.github.io/TestParameterInjector/docs/latest/com/google/testing/junit/testparameterinjector/TestParameter.TestParameterValuesProvider.html), + except that `provideValues()` was changed to `provideValues(Context)` where + [`Context`]( + https://google.github.io/TestParameterInjector/docs/latest/com/google/testing/junit/testparameterinjector/TestParameterValuesProvider.Context.html) + contains the test class and the other annotations. This allows for more generic + providers that take into account custom annotations with extra data, or the + implementation of abstract methods on a base test class. + + Example usage: + +```java +import com.google.testing.junit.testparameterinjector.TestParameterValuesProvider; + +private static final class MyProvider extends TestParameterValuesProvider { + @Override + public List<?> provideValues(Context context) throws Exception { + var testInstance = context.testClass().getDeclaredConstructor().newInstance(); + var fooList = ((MyBaseTestClass) testInstance).getFooList(); + // ... + + // OR + + var fooList = context.getOtherAnnotation(MyCustomAnnotation.class).fooList(); + // ... + } +} +``` + +- Fixed some theoretical non-determinism that could arise from Java reflection + methods + ## 1.14 - Fixed multiple constructors error when this library is used with Powermock. |