InstantSource

@SourceProvider(value = InstantValueSourceDataProvider::class)
annotation class InstantSource(val values: Array<String>)

Annotation to be utilized on a parameter of type Instant in a parameterized test. The annotated parameter;s value will be populated with a randomized value derived from the provided values array.

The values array should consist of instant string values, formatted according to the java.time.format.DateTimeFormatter.ISO_INSTANT standard.

Samples

fun testInstantSource(
    @InstantSource(
        values = [
            "2023-01-01T00:00:00.000Z",
            "2022-01-01T00:00:00.000Z",
            "2021-01-01T00:00:00.000Z"
        ]
    )
    value: Instant
) {
    assertThat(value).isLessThan(Instant.now())
}

Properties

Link copied to clipboard

An array of string representing instant, to be converted into Instant instances.