Matteo Mirk
03/14/2023, 11:44 AMwithData()
is only available in a container scope, so If a user tries to experiment using a StringSpec
, they will be met with a compilation error and left puzzled, as it just happened to me 😄sam
03/14/2023, 2:11 PMsam
03/14/2023, 2:11 PMMatteo Mirk
03/14/2023, 2:35 PMclass DataDrivenTest : FreeSpec({
"parametric test" {
withData(/*values*/) { ... ->
// test code
}
}
})
now the class compiles but I get a runtime error:
Cannot add a root test after the spec has been instantiated:which isn't very clear to be honest. Still, the docs fail to explain that you need to be inside a container scope to use withData(). And this applies to all the styles, that have both container and terminal scopes. Yes, the provided example shows that FunSpec's
context()
is used, but I believe it may not be immediately evident for library users, especially when starting out, and it should be explained in the docs.sam
03/14/2023, 2:36 PMMatteo Mirk
03/14/2023, 2:37 PMsam
03/14/2023, 2:38 PMhenrik
06/27/2024, 11:58 AMMatteo Mirk
06/27/2024, 12:32 PMwithData()
can be used. Luckily the documentation has been amended now.henrik
06/27/2024, 12:33 PMhenrik
06/27/2024, 12:34 PMMatteo Mirk
06/27/2024, 12:34 PMhenrik
06/27/2024, 12:35 PMMatteo Mirk
06/27/2024, 12:35 PMthat I posted your own answer to youyeah, that was my joke, as a monkey
henrik
06/27/2024, 12:35 PMhenrik
06/27/2024, 12:35 PMMatteo Mirk
06/27/2024, 12:36 PM