Questions tagged [zio-test]

ZIO Test is a zero dependency testing library that makes it easy to test effectual programs.

See here for more informations here: https://zio.dev/docs/usecases/usecases_testing

29 questions
1
vote
2 answers

How to extend the TestEnvironment of a ZIO Test

I want to test the following function: def curl(host: String, attempt: Int = 200): ZIO[Loggings with Clock, Throwable, Unit] If the environment would just use standard ZIO environments, like Console with Clock, the test would work out of the…
pme
  • 14,156
  • 3
  • 52
  • 95
0
votes
1 answer

SBT test does not run zio tests despite inclusion of test framework ZTestFramework

Edited following comments by @GastónSchabas to include a minimal reproducible example. I have a project in Scala 2.3.11, sbt 1.9.3, zio 2.0.15, zio-test 2.0.15. In the project, I have a mix of scalatest tests org.scalatest.flatspec.AnyFlatSpec and…
assaf
  • 3
  • 1
  • 3
0
votes
0 answers

ZIO mental model to add new endpoints

I am new to ZIO and would like to get some help on finding the right model to add a new endpoint. The existing service has 4 layers: layer A -> layer B -> layer C -> layer D (C uses the output of D as input, and creates a new output that is used by…
Dooora
  • 1
  • 1
0
votes
0 answers

How can I use Scala ZIO external library in Cloud Data Fusion pipeline?

I have downloaded the Jar for Zio library from link: https://jar-download.com/artifacts/dev.zio , But I am not sure how I can import same to build my pipelines. Can anyone please help me on same. Thanks in advance.
0
votes
1 answer

How to test Scala Spark UnitTest/DQ check using ZIO library?

I am new to Scala. I am trying to unit test ASSERTIONS for UT/DQ check for Scala Spark Dataframe using ZIO library. Can anyone help me out here if they have already worked on ZIO library before.
Kshitish Das
  • 67
  • 1
  • 7
0
votes
1 answer

Assert a failed effect with ZIO2 and zio-test

I am a beginner in the Scala / ZIO 2 world, and I am trying to write some tests for a simple service. so I have this method: def validate(id: String): ZIO[Any, Throwable, Unit] = { if (id == "invalid-id") { ZIO.fail("Invalid id") } } I…
elarous
  • 3
  • 3
0
votes
0 answers

How to write Junit test cases for ZIO Http?

Here's my code: import zhttp.http._ import zio._ import zhttp.http.{Http, Method, Request, Response, Status} import zhttp.service.Server case class Experiments(experimentId: String, variantId: String, accountId: String, deviceId: String, date:…
0
votes
1 answer

scala console error when testing sample IO using zio

Hi I've below ZIO ConsoleIO test. import zio._ import zio.Console import zio.test.Assertion.equalTo import zio.test._ object ConsoleIOSpec extends ZIOSpecDefault { val greet: ZIO[Any, Nothing, Unit] = for { name <- Console.readLine.orDie …
user51
  • 8,843
  • 21
  • 79
  • 158
0
votes
1 answer

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

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 <-…
Chris W.
  • 2,266
  • 20
  • 40
0
votes
2 answers

lift value out of / or into ZIO to assert it

I have a ZIO that looks like this: ZIO[transactor.Transactor[Task], Serializable, String] and I need to assert the String, that is in that ZIO with another plain String. So my question is: How can I assert the plain String, with the String in the…
helloworld
  • 127
  • 1
  • 1
  • 8
0
votes
1 answer

How to use regular time in ZIO-Test?

While working on zio-spark, we cannot race effects in Tests that are not using zio.Clock. The effects are not interrupted. It's there a way to fix that? package zio.spark.effect import zio._ import zio.test.TestAspect.timeout import…
jwinandy
  • 1,739
  • 12
  • 22
0
votes
2 answers

zio assert subtype of algebraic data type

Given algebraic data type sealed trait Result case object Success extends Result case class MyFailure(details: String) extends Result How to assert in zio-test that particular value is a Failure and it's details contain a particular substring? For…
pawel.panasewicz
  • 1,831
  • 16
  • 27
0
votes
0 answers

zio-logging behaves differently when testing scheduled tasks than on prod in ZIO

I'm stuck with testing repeatable task. Things work when run outside of test, but fail in tests. Looks like zio-logging behaves somehow differently when in test (as if it was "blocking"). When I replace logging with plaing Console calls it works, as…
Michal Ostruszka
  • 2,089
  • 2
  • 20
  • 23
0
votes
1 answer

Why is it not possible to extract the Layers in a variable in ZIO Test

When providing the Layers for my tests I stumbled over this strange behaviour, that it is not possible to extract the layers in a value. This code compiles: def spec: ZSpec[environment.TestEnvironment, Any] = suite("EnvironmentLoaderSuites")( …
pme
  • 14,156
  • 3
  • 52
  • 95
1
2