Packages

  • package root
    Definition Classes
    root
  • package zio
    Definition Classes
    root
  • package test

    _ZIO Test_ is a featherweight testing library for effectful programs.

    _ZIO Test_ is a featherweight testing library for effectful programs.

    The library imagines every spec as an ordinary immutable value, providing tremendous potential for composition. Thanks to tight integration with ZIO, specs can use resources (including those requiring disposal), have well- defined linear and parallel semantics, and can benefit from a host of ZIO combinators.

    import zio.test._
    import zio.test.environment.Live
    import zio.Clock.nanoTime
    import Assertion.isGreaterThan
    
    object MyTest extends DefaultRunnableSpec {
      def spec = suite("clock")(
        test("time is non-zero") {
          assertM(Live.live(nanoTime))(isGreaterThan(0))
        }
      )
    }
    Definition Classes
    zio
  • package environment

    The environment package contains testable versions of all the standard ZIO environment types through the TestClock, TestConsole, TestSystem, and TestRandom modules.

    The environment package contains testable versions of all the standard ZIO environment types through the TestClock, TestConsole, TestSystem, and TestRandom modules. See the documentation on the individual modules for more detail about using each of them.

    If you are using ZIO Test and extending RunnableSpec a TestEnvironment containing all of them will be automatically provided to each of your tests. Otherwise, the easiest way to use the test implementations in ZIO Test is by providing the TestEnvironment to your program.

    import zio.test.environment._
    
    myProgram.provideLayer(testEnvironment)

    Then all environmental effects, such as printing to the console or generating random numbers, will be implemented by the TestEnvironment and will be fully testable. When you do need to access the "live" environment, for example to print debugging information to the console, just use the live combinator along with the effect as your normally would.

    If you are only interested in one of the test implementations for your application, you can also access them a la carte through the make method on each module. Each test module requires some data on initialization. Default data is included for each as DefaultData.

    import zio.test.environment._
    
    myProgram.provideM(TestConsole.make(TestConsole.DefaultData))

    Finally, you can create a Test object that implements the test interface directly using the makeTest method. This can be useful when you want to access some testing functionality without using the environment type.

    import zio.test.environment._
    
    for {
      testRandom <- TestRandom.makeTest(TestRandom.DefaultData)
      n          <- testRandom.nextInt
    } yield n

    This can also be useful when you are creating a more complex environment to provide the implementation for test services that you mix in.

    Definition Classes
    test
  • Live
  • Restorable
  • TestClock
  • TestConsole
  • TestEnvironment
  • TestRandom
  • TestSystem

object TestClock extends Serializable

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. TestClock
  2. Serializable
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. final case class Data(duration: zio.Duration, sleeps: List[(zio.Duration, Promise[Nothing, Unit])], timeZone: ZoneId) extends Product with Serializable

    Data represents the state of the TestClock, including the clock time and time zone.

  2. final case class Sleep(duration: zio.Duration, promise: Promise[Nothing, Unit], fiberId: Id) extends Product with Serializable

    Sleep represents the state of a scheduled effect, including the time the effect is scheduled to run, a promise that can be completed to resume execution of the effect, and the fiber executing the effect.

  3. sealed abstract class SuspendedWarningData extends AnyRef
  4. final case class Test(clockState: Ref[Data], live: Live, annotations: Annotations, warningState: Synchronized[WarningData], suspendedWarningState: Synchronized[SuspendedWarningData]) extends Clock with TestClock with Product with Serializable
  5. sealed abstract class WarningData extends AnyRef

    WarningData describes the state of the warning message that is displayed if a test is using time by is not advancing the TestClock.

    WarningData describes the state of the warning message that is displayed if a test is using time by is not advancing the TestClock. The possible states are Start if a test has not used time, Pending if a test has used time but has not adjusted the TestClock, and Done if a test has adjusted the TestClock or the warning message has already been displayed.

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def adjust(duration: => zio.Duration): URIO[Has[TestClock], Unit]

    Accesses a TestClock instance in the environment and increments the time by the specified duration, running any actions scheduled for on or before the new time in order.

  5. val any: ZLayer[Has[Clock] with Has[TestClock], Nothing, Has[Clock] with Has[TestClock]]
  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  8. val default: ZLayer[Has[Live] with Has[Annotations], Nothing, Has[Clock] with Has[TestClock]]
  9. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  10. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  11. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  12. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  13. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  14. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  15. def live(data: Data): ZLayer[Has[Annotations] with Has[Live], Nothing, Has[Clock] with Has[TestClock]]

    Constructs a new Test object that implements the TestClock interface.

    Constructs a new Test object that implements the TestClock interface. This can be useful for mixing in with implementations of other interfaces.

  16. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  17. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  18. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  19. val save: ZIO[Has[TestClock], Nothing, UIO[Unit]]

    Accesses a TestClock instance in the environment and saves the clock state in an effect which, when run, will restore the TestClock to the saved state.

  20. def setDateTime(dateTime: => OffsetDateTime): URIO[Has[TestClock], Unit]

    Accesses a TestClock instance in the environment and sets the clock time to the specified OffsetDateTime, running any actions scheduled for on or before the new time in order.

  21. def setTime(duration: => zio.Duration): URIO[Has[TestClock], Unit]

    Accesses a TestClock instance in the environment and sets the clock time to the specified time in terms of duration since the epoch, running any actions scheduled for on or before the new time in order.

  22. def setTimeZone(zone: => ZoneId): URIO[Has[TestClock], Unit]

    Accesses a TestClock instance in the environment, setting the time zone to the specified time zone.

    Accesses a TestClock instance in the environment, setting the time zone to the specified time zone. The clock time in terms of nanoseconds since the epoch will not be altered and no scheduled actions will be run as a result of this effect.

  23. val sleeps: ZIO[Has[TestClock], Nothing, List[zio.Duration]]

    Accesses a TestClock instance in the environment and returns a list of times that effects are scheduled to run.

  24. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  25. val timeZone: URIO[Has[TestClock], ZoneId]

    Accesses a TestClock instance in the environment and returns the current time zone.

  26. def toString(): String
    Definition Classes
    AnyRef → Any
  27. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  28. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  29. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  30. object SuspendedWarningData
  31. object WarningData

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped