scalaziozio-test

ZIO Test does not allow define val inside suite?


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?


Solution

  • What about this:

    private def suite1 = {
      val name = ...
      val age = ...
    
      suite(
        test1,
        ...
        testN
      )
    }