Package

zio.test

mock

Permalink

package mock

Visibility
  1. Public
  2. All

Type Members

  1. final case class ArgumentExpectation[-M, I, A](method: Method[M, I, A], assertion: Assertion[I]) extends Product with Serializable

    Permalink

    An ArgumentExpectation[M, I, A] represents an expectation on input I arguments for capability of module M that returns an effect that may produce a single A.

  2. sealed trait Expectation[-M, +E, +A] extends AnyRef

    Permalink

    An Expectation[-M, +E, +A] is an immutable data structure that represents expectations on module M capabilities.

    An Expectation[-M, +E, +A] is an immutable data structure that represents expectations on module M capabilities.

    This structure is a monad, because we need the sequential composability and in Scala we get the convenient for-comprehension syntax for free.

    • Empty models expectation for no calls, the monadic unit value
    • Call models a call on M modules capability that takes arguments I and returns an effect that may fail with an error E or produce a single A
    • FlatMap models sequential composition of expectations

    The whole structure is not supposed to be consumed directly by the end user, instead it should be converted into a mocked environment (wrapped in layer) either explicitly via toLayer method or via implicit conversion.

  3. final case class Invocation[-M, I, A](method: Method[M, I, A], input: I, output: A) extends Product with Serializable

    Permalink

    An Invocation[M, I, A] models a single invocation of a Method[M, I, A], including both the input to the method invocation I and the output from the method invocation A.

  4. trait Method[-M, I, A] extends AnyRef

    Permalink

    A Model[M, I, A] represents a capability of module M that takes an input I and returns an effect that may produce a single A.

  5. trait Mock extends AnyRef

    Permalink
  6. sealed trait MockException extends Throwable

    Permalink

    A MockException is used internally by the mock framework to signal failed expectations to the test framework.

  7. trait Mockable[A] extends AnyRef

    Permalink

    The Mockable[A] represents a mock service builder used by the mock framework to construct a mock implementation from a mock.

  8. sealed trait ReturnExpectation[-I, +E, +A] extends AnyRef

    Permalink

    A ReturnExpectation[-I, E, +A] represents an expectation on output for capability of module M that given input arguments I returns an effect that may fail with an error E or produce a single A.

  9. trait Spyable[A] extends Mockable[A]

    Permalink

    Spyable[A] models the capability to spy on a service of type A.

    Spyable[A] models the capability to spy on a service of type A. Implementations must define both a method environment to genereate a live environment given a mock and a method mock to generate a mock given a live environment. Given these definitions, it is possible to convert a service to a mock, see and modify state based on method calls, inputs, and outputs, and then convert the mock back to a live environment to spy on the service.

Value Members

  1. object Expectation

    Permalink
  2. object Mock

    Permalink
  3. object MockClock

    Permalink
  4. object MockConsole

    Permalink
  5. object MockException extends Serializable

    Permalink
  6. object MockRandom

    Permalink
  7. object MockSystem

    Permalink
  8. object ReturnExpectation

    Permalink
  9. object Spyable

    Permalink

Ungrouped