autoparams.kotlin.CsvAutoKotlinArgumentsProvider.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of autoparams-kotlin Show documentation
Show all versions of autoparams-kotlin Show documentation
A Kotlin-specific addition to the AutoParams library, allowing for the automated generation of random parameters for unit testing in Kotlin. This extension is designed to leverage Kotlin's unique features for more powerful and flexible test data generation.
package autoparams.kotlin
import java.util.stream.Stream
import autoparams.CsvAutoArgumentsProvider
import autoparams.CsvAutoSource
import org.junit.jupiter.api.extension.ExtensionContext
import org.junit.jupiter.params.provider.Arguments
import org.junit.jupiter.params.provider.ArgumentsProvider
import org.junit.jupiter.params.support.AnnotationConsumer
class CsvAutoKotlinArgumentsProvider :
ArgumentsProvider,
AnnotationConsumer {
private val provider = CsvAutoArgumentsProvider()
override fun provideArguments(
context: ExtensionContext
): Stream = provider.provideArguments(context)
override fun accept(annotation: CsvAutoKotlinSource) {
provider.accept(
CsvAutoSource.ProxyFactory.create(
annotation.value,
annotation.textBlock.trimIndent(),
annotation.useHeadersInDisplayName,
annotation.quoteCharacter,
annotation.delimiter,
annotation.delimiterString,
annotation.emptyValue,
annotation.nullValues,
annotation.maxCharsPerColumn,
annotation.ignoreLeadingAndTrailingWhitespace
)
)
}
}