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 {
      def spec = suite("clock")(
        testM("time is non-zero") {
          assertM(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
  • package laws

    The laws package provides functionality for describing laws as values.

    The laws package provides functionality for describing laws as values. The fundamental abstraction is a set of ZLaws[Caps, R]. These laws model the laws that instances having a capability of type Caps are expected to satisfy. A capability Caps[_] is an abstraction describing some functionality that is common across different data types and obeys certain laws. For example, we can model the capability of two values of a type being compared for equality as follows:

    trait Equal[-A] {
      def equal(a1: A, a2: A): Boolean
    }

    Definitions of equality are expected to obey certain laws:

    1. Reflexivity - a1 === a1 2. Symmetry - a1 === a2 ==> a2 === a1 3. Transitivity - (a1 === a2) && (a2 === a3) ==> (a1 === a3)

    These laws define what the capabilities mean and ensure that it is safe to abstract across different instances with the same capability.

    Using ZIO Test, we can represent these laws as values. To do so, we define each law using one of the ZLaws constructors. For example:

    val transitivityLaw = ZLaws.Laws3[Equal]("transitivityLaw") {
      def apply[A: Equal](a1: A, a2: A, a3: A): TestResult =
        ???
    }

    We can then combine laws using the + operator:

    val reflexivityLaw: = ???
    val symmetryLaw:    = ???
    
    val equalLaws = reflexivityLaw + symmetryLaw + transitivityLaw

    Laws have a run method that takes a generator of values of type A and checks that those values satisfy the laws. In addition, objects can extend ZLawful to provide an even more convenient syntax for users to check that instances satisfy certain laws.

    object Equal extends Lawful[Equal]
    
    object Hash extends Lawful[Hash]
    
    object Ord extends Lawful[Ord]
    
    checkAllLaws(Equal + Hash + Ord)(Gen.anyInt)

    Note that capabilities compose seamlessly because of contravariance. We can combine laws describing different capabilities to construct a set of laws requiring that instances having all of the capabilities satisfy each of the laws.

    Definition Classes
    test
  • package mock
    Definition Classes
    test
  • package poly
    Definition Classes
    test
  • package reflect
    Definition Classes
    test
  • AbstractRunnableSpec
  • Annotations
  • Assertion
  • AssertionData
  • AssertionM
  • AssertionMData
  • AssertionValue
  • AssertionVariants
  • BoolAlgebra
  • BoolAlgebraM
  • CheckVariants
  • CompileVariants
  • DefaultRunnableSpec
  • DefaultTestReporter
  • Eql
  • FailureDetails
  • FailureRenderer
  • FunctionVariants
  • Gen
  • GenFailureDetails
  • GenZIO
  • RenderedResult
  • RunnableSpec
  • Sample
  • Sized
  • Spec
  • Summary
  • SummaryBuilder
  • TestAnnotation
  • TestAnnotationMap
  • TestAnnotationRenderer
  • TestArgs
  • TestAspect
  • TestExecutor
  • TestFailure
  • TestLogger
  • TestPlatform
  • TestReporter
  • TestRunner
  • TestSuccess
  • TestTimeoutException
  • TestVersion
  • TimeVariants
  • TimeoutVariants
  • ZTest

final case class Gen[-R, +A](sample: ZStream[R, Nothing, Sample[R, A]]) extends Product with Serializable

A Gen[R, A] represents a generator of values of type A, which requires an environment R. Generators may be random or deterministic.

Self Type
Gen[R, A]
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Gen
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Gen(sample: ZStream[R, Nothing, Sample[R, A]])

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. def <&>[R1 <: R, B](that: Gen[R1, B]): Gen[R1, (A, B)]

    A symbolic alias for zip.

  4. def <*>[R1 <: R, B](that: Gen[R1, B]): Gen[R1, (A, B)]

    A symbolic alias for cross.

  5. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  8. def cross[R1 <: R, B](that: Gen[R1, B]): Gen[R1, (A, B)]

    Composes this generator with the specified generator to create a cartesian product of elements.

  9. def crossWith[R1 <: R, B, C](that: Gen[R1, B])(f: (A, B) ⇒ C): Gen[R1, C]

    Composes this generator with the specified generator to create a cartesian product of elements with the specified function.

  10. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  11. def filter(f: (A) ⇒ Boolean): Gen[R, A]

    Filters the values produced by this generator, discarding any values that do not meet the specified predicate.

    Filters the values produced by this generator, discarding any values that do not meet the specified predicate. Using filter can reduce test performance, especially if many values must be discarded. It is recommended to use combinators such as map and flatMap to create generators of the desired values instead.

    val evens: Gen[Random, Int] = Gen.anyInt.map(_ * 2)
  12. def filterNot(f: (A) ⇒ Boolean): Gen[R, A]

    Filters the values produced by this generator, discarding any values that meet the specified predicate.

  13. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  14. def flatMap[R1 <: R, B](f: (A) ⇒ Gen[R1, B]): Gen[R1, B]
  15. def flatten[R1 <: R, B](implicit ev: <:<[A, Gen[R1, B]]): Gen[R1, B]
  16. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  17. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  18. def map[B](f: (A) ⇒ B): Gen[R, B]
  19. def mapM[R1 <: R, B](f: (A) ⇒ ZIO[R1, Nothing, B]): Gen[R1, B]

    Maps an effectual function over a generator.

  20. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  21. def noShrink: Gen[R, A]

    Discards the shrinker for this generator.

  22. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  23. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  24. def reshrink[R1 <: R, B](f: (A) ⇒ Sample[R1, B]): Gen[R1, B]

    Discards the shrinker for this generator and applies a new shrinker by mapping each value to a sample using the specified function.

    Discards the shrinker for this generator and applies a new shrinker by mapping each value to a sample using the specified function. This is useful when the process to shrink a value is simpler than the process used to generate it.

  25. def runCollect: ZIO[R, Nothing, List[A]]

    Runs the generator and collects all of its values in a list.

  26. def runCollectN(n: Int): ZIO[R, Nothing, List[A]]

    Repeatedly runs the generator and collects the specified number of values in a list.

  27. def runHead: ZIO[R, Nothing, Option[A]]

    Runs the generator returning the first value of the generator.

  28. val sample: ZStream[R, Nothing, Sample[R, A]]
  29. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  30. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  31. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  32. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  33. def withFilter(f: (A) ⇒ Boolean): Gen[R, A]
  34. def zip[R1 <: R, B](that: Gen[R1, B]): Gen[R1, (A, B)]

    Zips two generators together pairwise.

    Zips two generators together pairwise. The new generator will generate elements as long as either generator is generating elements, running the other generator multiple times if necessary.

  35. def zipWith[R1 <: R, B, C](that: Gen[R1, B])(f: (A, B) ⇒ C): Gen[R1, C]

    Zips two generators together pairwise with the specified function.

    Zips two generators together pairwise with the specified function. The new generator will generate elements as long as either generator is generating elements, running the other generator multiple times if necessary.

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped