ZIO Test does not allow define val inside suite?

38 Views Asked by At

I have a test suite structure like this:

override def spec = suite("Parent Suite") (
    suite1,
    ...
    suiteN
)

private def suite1 = suite(
    test1,
    ...
    testM
)
...
private def suiteN = suite(
    test1,
    ...
    testM
)


All tests of each suite uses same common variables, but seems like suite does not allow to define val inside like:

private def suite1 = suite(
    val name = ...
    val age = ...

    test1,
    ...
    testN
)

Therefore, I have to define all val repeatly in each test. How to avoid that?

1

There are 1 best solutions below

0
Gaël J On BEST ANSWER

What about this:

private def suite1 = {
  val name = ...
  val age = ...

  suite(
    test1,
    ...
    testN
  )
}