LocalTimeRangeSource

@SourceProvider(value = LocalDateTimeRangeDataProvider::class)
annotation class LocalTimeRangeSource(val min: String, val max: String, val increment: String = "PT1h", val ascending: Boolean = true, val timeFormat: String = "HH:mm")

Annotation to mark that the given LocalTime parameter should be populated with a LocalTime range starting from the minimum value min to the maximum value max with an increment in the direction specified by ascending. The default increment is 1 hour and the default ascending order is true.

Samples

/**
 * This will generate tests with random LocalTime values
 * between 12:00 and 19:00 with 1 hour increments
 */
@GeneratedParametersTest
fun testLocalTimeRangeSource(
    @LocalTimeRangeSource(
        min = "12:00",
        max = "19:00"
    )
    value: LocalTime
) {
    assertThat(value).isBetween(
        LocalTime.parse("12:00"),
        LocalTime.parse("19:00")
    )
}

Properties

Link copied to clipboard
val ascending: Boolean = true

A boolean to indicate the order of the values in the LocalTime range. Default is true, ascending order.

Link copied to clipboard

A string representing the period of increment for the LocalTime range. Should follow the ISO-8601 duration format e.g. "PT1h" for 1 hour, "PT30m" for 30 minutes. Default is "PT1h" for 1 hour

Link copied to clipboard
val max: String

The maximum value for the LocalTime range. Should be specified in timeFormat

Link copied to clipboard
val min: String

The minimum value for the LocalTime range. Should be specified in timeFormat

Link copied to clipboard

The format to be used for parsing min and max into LocalTime. Default is "HH:mm"