zio icon indicating copy to clipboard operation
zio copied to clipboard

zio-test: missing suite constructor from ZIO[..,..,Suite[Env, Err]]

Open eyalfa opened this issue 1 year ago • 3 comments

I was able to introduce such an implicit in my code, I believe it belongs in zio.test:

implicit def zioSuiteConstructor[R, R1, E <: E2, E1 <: E2, E2] : SuiteConstructor.WithOut[ZIO[R, E, Spec[R1, E1]], R with R1, E2] =
    new SuiteConstructor[ZIO[R, E, Spec[R1, E1]]] {
      override type OutEnvironment = R with R1
      override type OutError = E2

      override def apply(z: ZIO[R, E, Spec[R1, E1]])(implicit trace: Trace): Spec[R with R1, E2] = {
        val res: Spec[R with R1, E2] = Spec.scoped[R with R1](z.mapError(TestFailure.fail(_)))
        res
      }
    }

I'll push a pr for this unless there's any objection to adding this

eyalfa avatar May 21 '24 12:05 eyalfa

Can you explain when you get this message?

hearnadam avatar May 22 '24 03:05 hearnadam

I have a shared service used by multiple/all tests in the suite, I want to be able to do something like:

val suiteZ : ZIO[Svc with Env, Err, Suite[Svc with Env, Err] = ZIO.serviceWith[Svc]{svc =>
  suite(..){...}
}

and then:

override val spec = suite(...)(suiteZ, ...).provideShared(...)

eyalfa avatar May 22 '24 07:05 eyalfa

@eyalfa feel free to open a PR!

hearnadam avatar Jan 26 '25 19:01 hearnadam