Skip to main content
Version: 2.0.x


TestSystem supports deterministic testing of effects involving system properties.

With the increased usage of containers and runtimes like Kubernetes, more and more applications are being configured by means of environment variables. It is important to test this logic just like other parts of an application.

For this purpose ZIO Test exposes TestSystem module. Additionally, to setting the environment variables. It also allows for setting JVM system properties like in the code below:

import zio._
import zio.test._
import zio.test.Assertion._

for {
_ <- TestSystem.putProperty("", "VM")
result <-"")
} yield assertTrue(result == Some("VM"))

Internally, TestSystem maintains mappings of environment variables and system properties that can be set and accessed. It is worth noticing that no actual environment variables or system properties will be accessed or set as a result of these actions. So there will be no impact on other parts of the system.