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
  • Live
  • MockClock
  • MockConsole
  • MockEnvironment
  • MockRandom
  • MockSystem

object MockRandom extends Serializable

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

Type Members

  1. final case class Buffer(booleans: List[Boolean] = List.empty, bytes: List[Chunk[Byte]] = List.empty, chars: List[Char] = List.empty, doubles: List[Double] = List.empty, floats: List[Float] = List.empty, integers: List[Int] = List.empty, longs: List[Long] = List.empty, strings: List[String] = List.empty) extends Product with Serializable

    The buffer of the MockRandom.

  2. final case class Data(seed1: Int, seed2: Int, nextNextGaussians: scala.collection.immutable.Queue[Double] = Queue.empty) extends Product with Serializable

    The seed of the MockRandom.

  3. case class Mock(randomState: Ref[Data], bufferState: Ref[Buffer]) extends Service[Any] with Product with Serializable

    Adapted from @gzmo work in Scala.js (https://github.com/scala-js/scala-js/pull/780)

  4. trait Service[R] extends random.Random.Service[R]

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. val DefaultData: Data

    An arbitrary initial seed for the MockRandom.

  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. val clearBooleans: ZIO[MockRandom, Nothing, Unit]

    Accesses a MockRandom instance in the environment and clears the buffer of booleans.

  7. val clearBytes: ZIO[MockRandom, Nothing, Unit]

    Accesses a MockRandom instance in the environment and clears the buffer of bytes.

  8. val clearChars: ZIO[MockRandom, Nothing, Unit]

    Accesses a MockRandom instance in the environment and clears the buffer of characters.

  9. val clearDoubles: ZIO[MockRandom, Nothing, Unit]

    Accesses a MockRandom instance in the environment and clears the buffer of doubles.

  10. val clearFloats: ZIO[MockRandom, Nothing, Unit]

    Accesses a MockRandom instance in the environment and clears the buffer of floats.

  11. val clearInts: ZIO[MockRandom, Nothing, Unit]

    Accesses a MockRandom instance in the environment and clears the buffer of integers.

  12. val clearLongs: ZIO[MockRandom, Nothing, Unit]

    Accesses a MockRandom instance in the environment and clears the buffer of longs.

  13. val clearStrings: ZIO[MockRandom, Nothing, Unit]

    Accesses a MockRandom instance in the environment and clears the buffer of strings.

  14. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  15. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  17. def feedBooleans(booleans: Boolean*): ZIO[MockRandom, Nothing, Unit]

    Accesses a MockRandom instance in the environment and feeds the buffer with the specified sequence of booleans.

  18. def feedBytes(bytes: Chunk[Byte]*): ZIO[MockRandom, Nothing, Unit]

    Accesses a MockRandom instance in the environment and feeds the buffer with the specified sequence of chunks of bytes.

  19. def feedChars(chars: Char*): ZIO[MockRandom, Nothing, Unit]

    Accesses a MockRandom instance in the environment and feeds the buffer with the specified sequence of characters.

  20. def feedDoubles(doubles: Double*): ZIO[MockRandom, Nothing, Unit]

    Accesses a MockRandom instance in the environment and feeds the buffer with the specified sequence of doubles.

  21. def feedFloats(floats: Float*): ZIO[MockRandom, Nothing, Unit]

    Accesses a MockRandom instance in the environment and feeds the buffer with the specified sequence of floats.

  22. def feedInts(ints: Int*): ZIO[MockRandom, Nothing, Unit]

    Accesses a MockRandom instance in the environment and feeds the buffer with the specified sequence of integers.

  23. def feedLongs(longs: Long*): ZIO[MockRandom, Nothing, Unit]

    Accesses a MockRandom instance in the environment and feeds the buffer with the specified sequence of longs.

  24. def feedStrings(strings: String*): ZIO[MockRandom, Nothing, Unit]

    Accesses a MockRandom instance in the environment and feeds the buffer with the specified sequence of strings.

  25. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  26. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  27. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  28. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  29. def make(data: Data): UIO[MockRandom]

    Constructs a new MockRandom with the specified initial state.

    Constructs a new MockRandom with the specified initial state. This can be useful for providing the required environment to an effect that requires a Random, such as with ZIO!.provide.

  30. def makeMock(data: Data): UIO[Mock]

    Constructs a new Mock object that implements the MockRandom interface.

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

  31. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  32. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  33. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  34. def setSeed(seed: Long): ZIO[MockRandom, Nothing, Unit]

    Accesses a MockRandom instance in the environment and sets the seed to the specified value.

  35. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  36. def toString(): String
    Definition Classes
    AnyRef → Any
  37. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  38. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  39. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped