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

import assertk.Assert
import assertk.all
import assertk.assertThat
import assertk.assertions.isBetween
import assertk.assertions.isIn
import assertk.assertions.isLessThan
import assertk.assertions.support.expected
import com.wesleyhome.test.jupiter.annotations.GeneratedParametersTest
import com.wesleyhome.test.jupiter.annotations.StringSource
import com.wesleyhome.test.jupiter.annotations.datetime.InstantRangeSource
import com.wesleyhome.test.jupiter.annotations.datetime.InstantSource
import com.wesleyhome.test.jupiter.annotations.datetime.LocalDateRangeSource
import com.wesleyhome.test.jupiter.annotations.datetime.LocalDateSource
import com.wesleyhome.test.jupiter.annotations.datetime.LocalDateTimeRangeSource
import com.wesleyhome.test.jupiter.annotations.datetime.LocalDateTimeSource
import com.wesleyhome.test.jupiter.annotations.datetime.LocalTimeRangeSource
import com.wesleyhome.test.jupiter.annotations.datetime.LocalTimeSource
import com.wesleyhome.test.jupiter.annotations.datetime.RandomInstantSource
import com.wesleyhome.test.jupiter.annotations.number.DoubleRangeSource
import com.wesleyhome.test.jupiter.annotations.number.DoubleSource
import com.wesleyhome.test.jupiter.annotations.number.FloatRangeSource
import com.wesleyhome.test.jupiter.annotations.number.FloatSource
import com.wesleyhome.test.jupiter.annotations.number.IntRangeSource
import com.wesleyhome.test.jupiter.annotations.number.IntSource
import com.wesleyhome.test.jupiter.annotations.number.LongRangeSource
import com.wesleyhome.test.jupiter.annotations.number.LongSource
import java.time.Instant
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.LocalTime
import java.time.temporal.ChronoUnit

fun main() { 
   //sampleStart 
   /**
 * 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")
    )
} 
   //sampleEnd
}

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"