TestParameter.TestParameterValuesProvider in favor of its newer version TestParameterValuesProvider.Add context aware version of TestParameterValuesProvider. It is the same as the old TestParameter.TestParameterValuesProvider, except that provideValues() was changed to provideValues(Context) where Context 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:
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(); // ... } }
@TestParameter value given via a provider:private static final class FruitProvider implements TestParameterValuesProvider { @Override public List<?> provideValues() { return ImmutableList.of( value(new Apple()).withName("apple"), value(new Banana()).withName("banana")); } }
BigInteger and UnsignedLongTestParametersValues.name() optional. If missing, a name will be generated.protobuf-javalite (see issue #24)@Rule. For example: @Rule(ordering=3)..0)TestParameterInjector support for org.junit.runners.Parameterized, which was undocumented and thus unlikely to be used.@TestParameters can now also be used as a repeated annotation:// Newly added and recommended for new code @Test @TestParameters("{age: 17, expectIsAdult: false}") @TestParameters("{age: 22, expectIsAdult: true}") public void withRepeatedAnnotation(int age, boolean expectIsAdult){...} // The old way of using @TestParameters is still supported @Test @TestParameters({ "{age: 17, expectIsAdult: false}", "{age: 22, expectIsAdult: true}", }) public void withSingleAnnotation(int age, boolean expectIsAdult){...}
@TestParameters supports setting a custom test name:@Test @TestParameters(customName = "teenager", value = "{age: 17, expectIsAdult: false}") @TestParameters(customName = "young adult", value = "{age: 22, expectIsAdult: true}") public void personIsAdult(int age, boolean expectIsAdult){...}
protobuf-java by a dependency on protobuf-javalitej.l.r.Parameter. The minimum Android SDK version is now 24.ByteString and byte[]