Reputation: 378
I wonder, is there any example of implementing parameter type with Cucumber in Kotlin?
I've read the official doc but it doesn't explain how to wire it up.
I was looking around but haven't found anything really meaningful.
Any help with this?
Upvotes: 1
Views: 416
Reputation: 378
I found the solution to this. It seems that by just adding a class in the plug package all works
class NumberParameterTypeConfigurer : TypeRegistryConfigurer {
override fun locale(): Locale {
return Locale.ENGLISH
}
override fun configureTypeRegistry(typeRegistry: TypeRegistry?) {
typeRegistry?.defineParameterType(ParameterType(
"number",
"""\b(no|\d)\b""",
Int::class.java,
Transformer {
when (it) {
"no" -> 0
else -> it.toInt()
}
}
))
}
}
hope this can help somebody else
Upvotes: 1