Idiomatic way to test the error channel of a ZIO 2 effect with ZIO Test

Viewed 16

Is this the most idiomatic way to test a failing effect?

  def spec = suite("LookupPositionProviderSpec")(
    suite("determinePosition")(
      test("Unknown hints lead to 'NoPositionDetermined'") {
        for exit <- LookupPositionProvider.determinePosition(Seq(GsmFixtures.cellHintTowerGsm1.copy(cid = 4711))).exit
        yield assert(exit)(
          fails(
            equalTo(
              ProviderError(
                Lookup,
                NoPositionDetermined,
                Some("No position could be determined from List(CellHint(GSM,4711,Some(5891),Some(-70),None,None,None))")
              )
            )
          )
        )
      }.provide(TestLayers.findsNothingLookupPositionProvider)
    )
  ) 

I saw this old question (How to test an exception case with zio-test), but I am unsure if and what has changed since then with ZIO 2.

1 Answers
Related