Packages

p

zio

test

package test

_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 Predicate.gt

object MyTest extends DefaultRunnableSpec {
  suite("clock") {
    testM("time is non-zero") {
      assertM(nanoTime, gt(0))
    }
  }
}
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. test
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Package Members

  1. package mock

Type Members

  1. sealed trait Assertion[+A] extends AnyRef

    An Assertion[A] is the result of running a test, which may be ignore, success, or failure, with some message of type A.

  2. abstract class DefaultRunnableSpec extends RunnableSpec[String, ZTest[MockEnvironment, Any]]

    A default runnable spec that provides testable versions of all of the modules in ZIO (Clock, Random, etc).

  3. type ExecutedSpec[+L] = Spec[L, TestResult]

    An ExecutedSpec is a spec that has been run to produce test results.

  4. sealed trait ExecutionStrategy extends AnyRef
  5. sealed trait FailureDetails extends AnyRef

    FailureDetails keeps track of details relevant to failures.

  6. 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.

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

  7. class Predicate[-A] extends (=> A) => PredicateResult

    A Predicate[A] is capable of producing assertion results on an A.

    A Predicate[A] is capable of producing assertion results on an A. As a proposition, predicates compose using logical conjuction and disjunction, and can be negated.

  8. type PredicateResult = Assertion[PredicateValue]
  9. sealed trait PredicateValue extends AnyRef

    A PredicateValue keeps track of a predicate and a value, existentially hiding the type.

    A PredicateValue keeps track of a predicate and a value, existentially hiding the type. This is used internally by the library to provide useful error messages in the event of test failures.

  10. abstract class RunnableSpec[+L, +T] extends AnyRef

    A RunnableSpec has a main function and can be run by the JVM / Scala.js.

  11. final case class Sample[-R, +A](value: A, shrink: ZStream[R, Nothing, A]) extends Product with Serializable

    A sample is a single observation from a random variable, together with a stream of "shrinkings" used for minimization of "large" failures.

  12. final case class Spec[+L, +T](caseValue: SpecCase[L, T, Spec[L, T]]) extends Product with Serializable

    A Spec[L, T] is the backbone of _ZIO Test_.

    A Spec[L, T] is the backbone of _ZIO Test_. Every spec is either a suite, which contains other specs, or a test of type T. All specs are annotated with labels of type L.

  13. trait TestAspect[+LowerR, -UpperR, +LowerE, -UpperE] extends AnyRef

    A TestAspect is an aspect that can be weaved into specs.

    A TestAspect is an aspect that can be weaved into specs. You can think of an aspect as a polymorphic function, capable of transforming one test into another, possibly enlarging the environment or error type.

  14. type TestAspectPoly = TestAspect[Nothing, Any, Nothing, Any]

    A TestAspectPoly is a TestAspect that is completely polymorphic, having no requirements on error or environment.

  15. type TestExecutor[L, -T] = (Spec[L, T], ExecutionStrategy) => UIO[ExecutedSpec[L]]

    A TestExecutor[L, T] is capable of executing specs containing tests of type T, annotated with labels of type L.

  16. type TestReporter[-L] = (ExecutedSpec[L]) => UIO[Unit]

    A TestReporter[L] is capable of reporting test results annotated with labels L.

  17. type TestResult = Assertion[FailureDetails]
  18. abstract class TestRunner[L, -T] extends AnyRef

    A TestRunner[R, E, L] encapsulates all the logic necessary to run specs that require an environment R and may fail with an error E, using labels of type L.

    A TestRunner[R, E, L] encapsulates all the logic necessary to run specs that require an environment R and may fail with an error E, using labels of type L. Test runners require a test executor, a platform, and a reporter.

  19. type ZSpec[-R, +E, +L] = Spec[L, ZTest[R, E]]

    A ZSpec[R, E, L] is the canonical spec for testing ZIO programs.

    A ZSpec[R, E, L] is the canonical spec for testing ZIO programs. The spec's test type is a ZIO effect that requires an R, might fail with an E, might succeed with a TestResult, and whose nodes are annotated with labels L.

  20. implicit class ZSpecSyntax[R, E, L] extends AnyRef

    Adds syntax for adding aspects.

    Adds syntax for adding aspects.

    test("foo") { assert(42, equals(42)) } @@ ignore
  21. type ZTest[-R, +E] = ZIO[R, E, TestResult]

    A ZTest[R, E] is an effectfully produced test that requires an R and may fail with an E.

Value Members

  1. final def assert[A](value: => A, predicate: Predicate[A]): TestResult

    Asserts the given value satisfies the given predicate.

  2. final def assertM[R, A](value: ZIO[R, Nothing, A], predicate: Predicate[A]): ZTest[R, Nothing]

    Asserts the given effectfully-computed value satisfies the given predicate.

  3. final def check[R, A](rv: Gen[R, A])(predicate: Predicate[A]): ZTest[R, Nothing]

    Checks the predicate holds for "sufficient" numbers of samples from the given random variable.

  4. final def checkAll[R, A](rv: Gen[R, A])(predicate: Predicate[A]): ZTest[R, Nothing]

    Checks the predicate holds for all values from the given random variable.

    Checks the predicate holds for all values from the given random variable. This is useful for deterministic Gen that comprehensively explore all possibilities in a given domain.

  5. final def checkSome[R, A](n: Int)(rv: Gen[R, A])(predicate: Predicate[A]): ZTest[R, Nothing]

    Checks the predicate holds for the specified number of samples from the given random variable.

  6. final def fail[E](cause: Cause[E]): TestResult

    Creates a failed test result with the specified runtime cause.

  7. final def suite[L, T](label: L)(specs: Spec[L, T]*): Spec[L, T]

    Builds a suite containing a number of other specs.

  8. final def test[L](label: L)(assertion: => TestResult): ZSpec[Any, Nothing, L]

    Builds a spec with a single pure test.

  9. final def testM[L, T](label: L)(assertion: T): Spec[L, T]

    Builds a spec with a single effectful test.

  10. object Assertion
  11. object DefaultTestReporter
  12. object DefaultTestRunner extends TestRunner[String, ZTest[MockEnvironment, Any]]

    A Runner that provides a default testable environment.

  13. object ExecutionStrategy
  14. object FailureDetails
  15. object Gen extends Serializable
  16. object Predicate
  17. object PredicateValue
  18. object Sample extends Serializable
  19. object Spec extends Serializable
  20. object TestAspect
  21. object TestExecutor

Inherited from AnyRef

Inherited from Any

Ungrouped