LocalDateTimeRangeSource

@SourceProvider(value = LocalDateTimeRangeDataProvider::class)
annotation class LocalDateTimeRangeSource(val min: String, val max: String, val increment: String = "PT1h", val ascending: Boolean = true, val dateTimeFormat: String = "yyyy-MM-dd HH:mm")

Annotation to indicate that the annotated LocalDateTime parameter should be populated with a LocalDateTime range from min to max with an increment step in the ascending direction. The default increment is 1 hour. The default ascending 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
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val max: String
Link copied to clipboard
val min: String