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.clock.nanoTime
    import Assertion.isGreaterThan
    
    object MyTest extends DefaultRunnableSpec {
      suite("clock") {
        testM("time is non-zero") {
          assertM(nanoTime, isGreaterThan(0))
        }
      }
    }
    Definition Classes
    zio
  • package mock

    The mock package contains testable versions of all the standard ZIO environment types through the MockClock, MockConsole, MockSystem, and MockRandom modules.

    The mock package contains testable versions of all the standard ZIO environment types through the MockClock, MockConsole, MockSystem, and MockRandom modules. See the documentation on the individual modules for more detail about using each of them.

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

    import zio.test.mock._
    
    myProgram.provideManaged(mockEnvironmentManaged)

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

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

    import zio.test.mock._
    
    myProgram.provideM(MockConsole.make(MockConsole.DefaultData))

    Finally, you can create a Mock object that implements the mock interface directly using the makeMock method. This can be useful when you want to access some mocking functionality without using the environment type.

    import zio.test.mock._
    
    for {
      mockRandom <- MockRandom.makeMock(MockRandom.DefaultData)
      n          <- mockRandom.nextInt
    } yield n

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

    Definition Classes
    test
  • object MockClock extends Serializable
    Definition Classes
    mock
  • Data
  • FiberData
  • Mock
  • Service

case class Mock(clockState: Ref[Data], fiberState: FiberRef[FiberData]) extends Service[Any] with Product with Serializable

Linear Supertypes
Product, Equals, Service[Any], scheduler.Scheduler.Service[Any], clock.Clock.Service[Any], Serializable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Mock
  2. Product
  3. Equals
  4. Service
  5. Service
  6. Service
  7. Serializable
  8. AnyRef
  9. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Mock(clockState: Ref[Data], fiberState: FiberRef[FiberData])

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. final def adjust(duration: Duration): UIO[Unit]

    Increments the current clock time by the specified duration.

    Increments the current clock time by the specified duration. Any effects that were scheduled to occur on or before the new time will immediately be run.

    Definition Classes
    MockService
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. val clockState: Ref[Data]
  7. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  8. final def currentDateTime: UIO[OffsetDateTime]

    Returns the current clock time as an OffsetDateTime.

    Returns the current clock time as an OffsetDateTime.

    Definition Classes
    Mock → Service
  9. final def currentTime(unit: TimeUnit): UIO[Long]

    Returns the current clock time in the specified time unit.

    Returns the current clock time in the specified time unit.

    Definition Classes
    Mock → Service
  10. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  11. val fiberState: FiberRef[FiberData]
  12. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  13. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  14. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  15. final val nanoTime: IO[Nothing, Long]

    Returns the current clock time in nanoseconds.

    Returns the current clock time in nanoseconds.

    Definition Classes
    Mock → Service
  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. def productElementNames: Iterator[String]
    Definition Classes
    Product
  20. val scheduler: ZIO[Any, Nothing, Scheduler]

    Returns an effect that creates a new Scheduler backed by this MockClock.

    Returns an effect that creates a new Scheduler backed by this MockClock.

    Definition Classes
    Mock → Service
  21. final def setTime(duration: Duration): UIO[Unit]

    Sets the current clock time to the specified time.

    Sets the current clock time to the specified time. Any effects that were scheduled to occur on or before the new time will immediately be run.

    Definition Classes
    MockService
  22. final def setTimeZone(zone: ZoneId): UIO[Unit]

    Sets the time zone to the specified time zone.

    Sets the time zone to the specified time zone. The clock time in terms of nanoseconds since the epoch will not be adjusted and no scheduled effects will be run as a result of this method.

    Definition Classes
    MockService
  23. final def sleep(duration: Duration): UIO[Unit]

    Semantically blocks the current fiber until the clock time is equal to or greater than the specified duration.

    Semantically blocks the current fiber until the clock time is equal to or greater than the specified duration. Once the clock time is adjusted to on or after the duration, the fiber will automatically be resumed.

    Definition Classes
    Mock → Service
  24. val sleeps: UIO[List[Duration]]

    Returns a list of the times at which all queued effects are scheduled to resume.

    Returns a list of the times at which all queued effects are scheduled to resume.

    Definition Classes
    MockService
  25. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  26. val timeZone: UIO[ZoneId]

    Returns the time zone.

    Returns the time zone.

    Definition Classes
    MockService
  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()

Inherited from Product

Inherited from Equals

Inherited from Service[Any]

Inherited from scheduler.Scheduler.Service[Any]

Inherited from clock.Clock.Service[Any]

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped