for the first, the tests aren't nested and so when...
# kotest
s
for the first, the tests aren't nested and so when they start to repeat through the inner loop on the second outer loop, I get 'duplicate' test name errors. but if I create that test internally, now there are two tests with that name. Here is a demonstration of the issue by just adding a prefix to the test
s
Can you paste up the code for the first example
save me typing it all out
s
Copy code
class PrintDrlTest : FreeSpec({

    "test" - {
        forAll("a", "b", "c") { outer ->
            forAll("1", "2", "3") { inner ->
                println("$outer$inner")
            }
        }
    }

    "test 2" - {
        forAll("a", "b", "c") { outer ->
            "prefix: $outer" - {
                forAll("1", "2", "3") { inner ->
                    println("$outer$inner")
                }
            }
        }
    }
})
I'm on 4.4.1
s
Ah ok I see
Take this part:
Copy code
"test" - {
        forAll("a", "b", "c") { outer ->
            forAll("1", "2", "3") { inner ->
                println("$outer$inner")
            }
        }
    }
that's just two nested loops, and the outer loop won't be joined with the inner loop for a test name
like it looks like the tests will be nested but they won't be because you're not creating inner tests
It's no difference to going
Copy code
test("a") { }
test("1") { }
test("2") { }
test("b") { }
test("1") { }
test("2") { }
s
for either of those they're not really nested? How do I get them to nest then? I tried
test 2
without the prefix and have the issue of the duplicate top level tests
see my most recent pictures in the main channel
s
If you want to nest tests, then just roll your own loop
Copy code
"test" - {
        listOf("a", "b", "c").forEach { outer ->
           "$outer" - {
                 listOf("1", "2", "3").forEach { inner ->
                        "$inner" - {
                              println("$outer$inner")
                        }
                  }
               }
        }
    }
s
what does the forAll accomplish then? If it needs to be nested in a test to begin with, and you can't nest them without this issue.
s
forAll is special syntax that will create tests for you (basically doing what I pasted above)
s
yes I realize that.
just seems like it should work to nest as well. I'll just roll my own loop.
s
nested tests are created at runtime, because it's just nested lambdas right. So when the code is compiled with forAll it binds to the closest statically created test loop. so in your example, the closest loop is the top level "test"- block. The inner block doesn't exist until runtime.
s
oh. that makes sense. alright. thanks!
s
I can see why it's not intuitive. Let me make a ticket to see if we can make the whole thing defer until runtime.
s
awesome. thanks for that!
👍🏻 1
s
thanks for the feedback, always good to keep improving things
s
welcome! I was just really confused by it all. couldn't understand why it was making the top ones twice.
s
Wasn't obvious to me either at first lol