Hi! Can someone point me to an example of combini...
# kotest
v
Hi! Can someone point me to an example of combining a test factory with data driven tests please?
I'm trying to run a test factory over every item in a collection. Thanks!
I guess more generally is it possible to add multiple tests to a data driven test like:
Copy code
withData(listOf("a", "b", "c")) {
    it("should contain single character") { ... }
    it("should be lowercase") { .. }
}
When I try to do something like that either directly or via a test factory I get a
io.kotest.core.spec.InvalidDslException: Cannot add a root test after the spec has been instantiated
s
I think your issue here is probably just the way you're nesting. What spec type are you using?
v
I've tried both FunSpec and DescribeSpec
s
Let me try it real quick
Yeah you cant' do it
You could roll your own data tests by just forEaching on the list, and then you can have tests inside
Copy code
listOf("a", "b", "c").foreach {
    it("should contain single character") { ... }
    it("should be lowercase") { .. }
}
v
That's what I ended up doing, but wanted to make sure I wasn't missing something. Thanks for taking a look.
e
I started looking into if we could enable inclusion of test factories in container scopes at one point. I think it looks doable but might be missing something.. https://github.com/kotest/kotest/pull/3504/files#diff-47132c0dfa796bddf113c2e7b81d0fbbf7db278c3f9838f96ec32838057d9527