I wrote a few tests like
"x" should {
val myMultipleTestsObject = initX
"validate x" in {
}
"validate x 2" in {
}
}
"y" should {
val myMultipleTestsObject = initY
"validate y" in {
}
"validate y 2" in {
}
}
I'm trying to run for example only the "y" test, and i found out that the body of "x" is also evaluated when it's being registered and thus it excutes "initX"
for me initX and initY are long running tasks that I would like to avoid when running only one test.
I solved this by adding lazy to myMultipleTestsObject.
but is this the expected behaviour? isnt there a more idiomatic way to prepare variables for each test without them being evaluated on registration time?