Skip to main content
Version: 2.x

Conditional Aspects

When we apply a conditional aspect, it will run the spec only if the specified predicate is satisfied.

  • ifEnv โ€” Only runs a test if the specified environment variable satisfies the specified assertion.
  • ifEnvSet โ€” Only runs a test if the specified environment variable is set.
  • ifProp โ€” Only runs a test if the specified Java property satisfies the specified assertion.
  • ifPropSet โ€” Only runs a test if the specified Java property is set.
import zio._
import zio.test.{test, _}
import zio.test.TestAspect._

test("a test that will run if the product is deployed in the testing environment") {
???
} @@ ifEnv("ENV")(_ == "testing")

test("a test that will run if the java.io.tmpdir property is available") {
???
} @@ ifEnvSet("java.io.tmpdir")

ZIO Chat

Hi there! ๐Ÿ‘‹ I'm ZIO Chat, your friendly neighborhood ZIO expert. I'm here to help you navigate the world of ZIO. Whether you're a seasoned pro or just starting out, fire away with your ZIO questions. I will hit you back with the best insights I've got. Let's dive into the world of ZIO together!