Skip to content

Latest commit

 

History

History
254 lines (187 loc) · 9.22 KB

File metadata and controls

254 lines (187 loc) · 9.22 KB

1.22

  • Kotlin default parameters: Added support for an alternative way to specify test values in Kotlin:

    Examples:

import com.google.testing.junit.testparameterinjector.KotlinTestParameters.testValues
import com.google.testing.junit.testparameterinjector.KotlinTestParameters.namedTestValues
import com.google.testing.junit.testparameterinjector.KotlinTestParameters.testValuesIn

@TestParameter limit: Int = testValues(20, 100),

@TestParameter testCase: AgeCheckTestCase = namedTestValues(
    "teenager"  to AgeCheckTestCase(17, false),
    "young adult"  to AgeCheckTestCase(22, true),
),

@TestParameter invalidRequest: Request =
    testValuesIn(readRequestsFromFile("invalid_requests.json")),
  • Minor breaking change: Because of the above, Kotlin test methods with default parameters will no longer work. These defaults would never have been used anyway.
  • Minor breaking change: TestParameterInjector will now fail tests that specify both @TestParameters on the method and @TestParameter on a parameter.

1.21

  • Add public method computeTestMethods(List<FrameworkMethod> methods) to TestParameterInjector API. This can be useful for creating custom extensions of TestParameterInjector.

1.20

  • New Compile-Time Dependency on Kotlin: The library now includes a compile-time dependency on the Kotlin Standard Library (kotlin-stdlib) and Kotlin Reflection (kotlin-reflect). This is required to properly support Kotlin tests (see the next two changes).

    If this dependency is causing problems, please let us know by raising an issue. If there is enough need for this, we can justify adding an extra artefact that omits the Kotlin part.

  • Bugfix for Kotlin v2.2.20: Get parameter names via Kotlin reflection because those via Java reflection have changed to include the class.

  • Fix the breaking change in TestParameterInjector v1.19: By getting the parameter names via Kotlin, the breaking change in 1.19 is no longer breaking when directly upgrading to 1.20

  • Breaking change: TestParametersValuesProvider must return at least one value. If your use case requires (sometimes) disabling the test by returning zero values, override TestParametersValuesProvider.valuesListCanBeEmptyWhichMeansThatTheTestWillBeSkipped().

1.19

1.18

  • Made some internal JUnit4 methods of TestParameterInjector public:

    • computeTestMethods()
    • methodBlock()
    • methodInvoker()

    These allow any client to combine TestParameterInjector with another JUnit4 runner by manually creating a TestParameterInjector instance and calling these methods from the combined JUnit4 runner.

1.17

  • Added support for parsing java.time.Duration from a string. Example:
@Test
public void myTest(@TestParameter({"1d", "2h20min", "10.5ms"}) Duration duration){...}

1.16

1.15

  • 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();
    // ...
  }
}
  • 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. See #40.

1.13

  • Add support for setting a custom name for a @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"));
  }
}
  • Add support for BigInteger and UnsignedLong
  • JUnit4: Fix for interrupted test cases causing random failures with thread reuse (porting the earlier fix in JUnit4)

1.12

  • Tweak to the test name generation: Show the parameter name if its value is potentially ambiguous (e.g. null, "" or "123").
  • Made TestParametersValues.name() optional. If missing, a name will be generated.

1.11

  • Replaced deprecated call to org.yaml.snakeyaml.constructor.SafeConstructor

1.10

  • Removed dependency on protobuf-javalite (see issue #24)

1.9

  • Bugfix: Support explicit ordering by the JUnit4 @Rule. For example: @Rule(ordering=3).
  • Potential test name change: Test names are no longer dependent on the locale of the machine running it (e.g. doubles with integer values are always formatted with a trailing .0)

1.8

  • Add support for JUnit5 (Jupiter)

1.7

  • Remove TestParameterInjector support for org.junit.runners.Parameterized, which was undocumented and thus unlikely to be used.

1.6

  • Bugfixes
  • Better documentation

1.5

  • @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){...}
  • Test names with very long parameter strings are abbreviated differentily: In some cases, more characters are allowed.

1.4

  • Bugfix: Run test methods declared in a base class (instead of throwing an exception)
  • Test names with very long parameter strings are now abbreviated with a snippet of the shortened parameter
  • Duplicate test names are given a suffix for deduplication
  • Replaced dependency on protobuf-java by a dependency on protobuf-javalite

1.3

  • Treat 'null' as a magic string that results in a null value

1.2

  • Don't use the parameter name if it's not explicitly provided by the compiler
  • Add support for older Android SDK versions by removing the dependency on j.l.r.Parameter. The minimum Android SDK version is now 24.

1.1

  • Add support for ByteString and byte[]