In this sample code, I have 2 Specs, and I want to do some before action to both of them, then I have to call @@ TestAspect.before to both test. If the number of tests increase, add @@ TestAspect to all test/suite sounds not a good idea, how to avoid this?
import zio._
import zio.test._
import zio.test.Assertion._
object WorldSpec extends ZIOSpecDefault {
def spec = suite("HelloWorldSpec")(
test("simple test") {
assertTrue(1 + 1 == 2)
}
) @@ TestAspect.before(
doBeforeFunctions
)
}
object UniverseSpec extends ZIOSpecDefault {
def spec = suite("HelloUniverseSpec")(
test("sayHello correctly displays output") {
assertTrue(2 + 2 == 4)
}
) @@ TestAspect.before(
doBeforeFunction
)
}
Well, you could always do old-good-subclassing if you wanted to ...
But ... why? At this point, it seems like writing
@@ beforein every spec is almost less effort, and in no time, you are going to diverge more anyway ...