AbstractAnnotatedParameterDataProvider
abstract class AbstractAnnotatedParameterDataProvider<T : Any, A : Annotation> : AbstractParameterDataProvider<T>
Base for a provider driven by a parameter annotation.
Extends AbstractParameterDataProvider with the annotation type A, so the provider claims a parameter only when it is of type T and carries A. Read the annotation off the parameter with findAnnotation.
@Target(AnnotationTarget.VALUE_PARAMETER)
@Retention(AnnotationRetention.RUNTIME)
@SourceProvider(EvenSourceDataProvider::class)
annotation class EvenSource(val max: Int)
class EvenSourceDataProvider : AbstractAnnotatedParameterDataProvider<Int, EvenSource>() {
override fun createParameterOptionsData(testParameter: TestParameter): List<Int> =
(0..findAnnotation(testParameter)!!.max step 2).toList()
}Content copied to clipboard