I've started using kotest:4.0.5 (kotlintest) and having problem with stringSpec function nested in describe clause.
Example:
class SellerTest : DescribeSpec({
describe("Registration") {
context("Not existing user") {
include(emailValidation()
}
}
})
fun emailValidation() = stringSpec {
"Email validation" {
forAll(
row("test.com"),
row("123123123123123")
) { email ->
assertSoftly {
val exception =
shouldThrow<ServiceException> { Email(email) }
}
}
}
}
If include(emailValidation()) is outside describe clause then correctly works.
Have you any idea how to nest specs/functions in clauses?
You can only use
includeat the top level. This is part of how factory tests (what the include keyword is used for) are implemented (perhaps that will be relaxed in a future release).You can move the whole thing into the factory though.
And you can parameterize the naming all you want, as that's just strings, for example:
If you are not parameterizing, then there's little point in having the test factory. Just declare the test inline IMO.