LocalDateSource
Annotation to indicate that the annotated LocalDate parameter should be populated with a random value from the provided values array.
Samples
/**
* This will generate 5 tests with the values "2020-01-01", "2021-01-01", "2022-01-01", "2023-01-01", "2024-01-01"
*/
@GeneratedParametersTest
fun testLocalDateSource(@LocalDateSource(values = ["2020-01-01", "2021-01-01", "2022-01-01", "2023-01-01", "2024-01-01"]) value: LocalDate) {
assertThat(value).isLessThan(LocalDate.now())
}
/**
* This will generate 5 tests with the values "01/01/2020", "01/01/2021", "01/01/2022", "01/01/2023", "01/01/2024"
* The values will be parsed using the format "MM/dd/yyyy"
*/
@GeneratedParametersTest
fun testLocalDateSourceWithFormat(
@LocalDateSource(
values = ["01/01/2020", "01/01/2021", "01/01/2022", "01/01/2023", "01/01/2024"],
dateFormat = "MM/dd/yyyy"
)
value: LocalDate
) {
assertThat(value).isLessThan(LocalDate.now())
}Content copied to clipboard