Skip to content

Latest commit

 

History

History
40 lines (31 loc) · 1.09 KB

README.adoc

File metadata and controls

40 lines (31 loc) · 1.09 KB

Generex integration

build.gradle.kts
// Add for Generex integration
testImplementation("com.appmattus.fixture:fixture-generex:<latest-version>")

The Generex library generates random strings from a regular expression.

Including the fixture-generex dependency in your project adds a regexToRandom function to factory and property generators.

data class DataClass(val index: String, val value: String)

val indexRegex = "[a-z][0-9]".toRegex()
val valueRegex = "[A-Z]{3}".toRegex()

val fixture = kotlinFixture {
    factory<String> { regexToRandom(indexRegex) }

    property(DataClass::value) { regexToRandom(valueRegex) }
}

println(fixture<DataClass>()) // DataClass(index=m3, value=CGJ)
Be careful with object creation inside the generation function as it will be called for every instance of the object you create.