Package

zio

test

Permalink

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 Assertion.isGreaterThan

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

Type Members

  1. abstract class AbstractRunnableSpec extends AnyRef

    Permalink
    Annotations
    @EnableReflectiveInstantiation()
  2. sealed trait AssertResult[+A] extends Product with Serializable

    Permalink

    An AssertResult[A] is the result of running an assertion on a value.

    An AssertResult[A] is the result of running an assertion on a value. Assert results compose using logical && and || and all information will be preserved to provide robust reporting of test results.

  3. class Assertion[-A] extends (⇒ A) ⇒ AssertResult[Either[AssertionValue, Unit]]

    Permalink

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

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

  4. sealed trait AssertionValue extends AnyRef

    Permalink

    An AssertionValue keeps track of a assertion and a value, existentially hiding the type.

    An AssertionValue keeps track of a assertion 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.

  5. trait CheckVariants extends AnyRef

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

    Permalink

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

  7. type ExecutedSpec[+L, +E, +S] = Spec[L, Either[TestFailure[E], TestSuccess[S]]]

    Permalink

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

  8. sealed trait ExecutionStrategy extends AnyRef

    Permalink
  9. final case class FailureDetails(fragment: AssertionValue, whole: AssertionValue) extends Product with Serializable

    Permalink

    FailureDetails keeps track of details relevant to failures.

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

    Permalink

    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.

  11. case class RenderedResult(caseType: CaseType, label: String, status: Status, offset: Int, rendered: Seq[String]) extends Product with Serializable

    Permalink
  12. abstract class RunnableSpec[L, T, E, S] extends AbstractRunnableSpec

    Permalink

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

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

    Permalink

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

  14. trait Sized extends AnyRef

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

    Permalink

    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.

  16. trait TestAspect[+LowerR, -UpperR, +LowerE, -UpperE, +LowerS, -UpperS] extends AnyRef

    Permalink

    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, error, or success type.

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

    Permalink

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

  18. type TestExecutor[L, -T, +E, +S] = (Spec[L, T], ExecutionStrategy) ⇒ UIO[ExecutedSpec[L, E, S]]

    Permalink

    A TestExecutor[L, T, E, S] is capable of executing specs containing tests of type T, annotated with labels of type L, that may fail with an E or succeed with a S.

  19. sealed trait TestFailure[+E] extends AnyRef

    Permalink
  20. trait TestLogger extends AnyRef

    Permalink
  21. type TestReporter[-L, -E, -S] = (Duration, ExecutedSpec[L, E, S]) ⇒ URIO[TestLogger, Unit]

    Permalink

    A TestReporter[L, E, S] is capable of reporting test results annotated with labels L, error type E, and success type S.

  22. type TestResult = AssertResult[Either[FailureDetails, Unit]]

    Permalink
  23. case class TestRunner[L, -T, E, S](executor: TestExecutor[L, T, E, S], platform: Platform = ..., reporter: TestReporter[L, E, S] = DefaultTestReporter()) extends Product with Serializable

    Permalink

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

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

  24. sealed trait TestSuccess[+S] extends AnyRef

    Permalink
  25. trait TimeoutStrategy extends AnyRef

    Permalink

    A TimeoutStrategy adds logic to a ZSpec to handle long-running and potentially non-terminating tests.

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

    Permalink

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

    A ZSpec[R, E, L, S] 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 an S, and whose nodes are annotated with labels L.

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

    Permalink

    Adds syntax for adding aspects.

    Adds syntax for adding aspects.

    test("foo") { assert(42, equalTo(42)) } @@ ignore
  28. type ZTest[-R, +E, +S] = ZIO[R, TestFailure[E], TestSuccess[S]]

    Permalink

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

Value Members

  1. object AssertResult extends Serializable

    Permalink
  2. object Assertion

    Permalink
  3. object AssertionValue

    Permalink
  4. object DefaultTestReporter

    Permalink
  5. object DefaultTestRunner extends TestRunner[String, ZTest[MockEnvironment, Any, Any], Any, Any]

    Permalink

    A Runner that provides a default testable environment.

  6. object ExecutionStrategy

    Permalink
  7. object Gen extends Serializable

    Permalink
  8. object RenderedResult extends Serializable

    Permalink
  9. object Sample extends Serializable

    Permalink
  10. object Sized

    Permalink
  11. object Spec extends Serializable

    Permalink
  12. object TestAspect

    Permalink
  13. object TestExecutor

    Permalink
  14. object TestFailure

    Permalink
  15. object TestLogger

    Permalink
  16. object TestPlatform

    Permalink

    TestPlatform provides information about the platform tests are being run on to enable platform specific test configuration.

  17. object TestReporter

    Permalink
  18. object TestSuccess

    Permalink
  19. object TimeoutStrategy

    Permalink
  20. final def assert[A](value: ⇒ A, assertion: Assertion[A]): TestResult

    Permalink

    Checks the assertion holds for the given value.

  21. final def assertM[R, A](value: ZIO[R, Nothing, A], assertion: Assertion[A]): ZTest[R, Nothing, Unit]

    Permalink

    Checks the assertion holds for the given effectfully-computed value.

  22. final def check[R, A, B, C, D](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C], rv4: Gen[R, D])(test: (A, B, C, D) ⇒ TestResult): ZTest[R, Nothing, Unit]

    Permalink

    A version of check that accepts four random variables.

    A version of check that accepts four random variables.

    Definition Classes
    CheckVariants
  23. final def check[R, A, B, C](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C])(test: (A, B, C) ⇒ TestResult): ZTest[R, Nothing, Unit]

    Permalink

    A version of check that accepts three random variables.

    A version of check that accepts three random variables.

    Definition Classes
    CheckVariants
  24. final def check[R, A, B](rv1: Gen[R, A], rv2: Gen[R, B])(test: (A, B) ⇒ TestResult): ZTest[R, Nothing, Unit]

    Permalink

    A version of check that accepts two random variables.

    A version of check that accepts two random variables.

    Definition Classes
    CheckVariants
  25. final def check[R, A](rv: Gen[R, A])(test: (A) ⇒ TestResult): ZTest[R, Nothing, Unit]

    Permalink

    Checks the test passes for "sufficient" numbers of samples from the given random variable.

    Checks the test passes for "sufficient" numbers of samples from the given random variable.

    Definition Classes
    CheckVariants
  26. final def checkAll[R, A, B, C, D](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C], rv4: Gen[R, D])(test: (A, B, C, D) ⇒ TestResult): ZTest[R, Nothing, Unit]

    Permalink

    A version of checkAll that accepts four random variables.

    A version of checkAll that accepts four random variables.

    Definition Classes
    CheckVariants
  27. final def checkAll[R, A, B, C](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C])(test: (A, B, C) ⇒ TestResult): ZTest[R, Nothing, Unit]

    Permalink

    A version of checkAll that accepts three random variables.

    A version of checkAll that accepts three random variables.

    Definition Classes
    CheckVariants
  28. final def checkAll[R, A, B](rv1: Gen[R, A], rv2: Gen[R, B])(test: (A, B) ⇒ TestResult): ZTest[R, Nothing, Unit]

    Permalink

    A version of checkAll that accepts two random variables.

    A version of checkAll that accepts two random variables.

    Definition Classes
    CheckVariants
  29. final def checkAll[R, A](rv: Gen[R, A])(test: (A) ⇒ TestResult): ZTest[R, Nothing, Unit]

    Permalink

    Checks the test passes for all values from the given random variable.

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

    Definition Classes
    CheckVariants
  30. final def checkAllM[R, A, B, C, D](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C], rv4: Gen[R, D])(test: (A, B, C, D) ⇒ ZIO[R, Nothing, TestResult]): ZTest[R, Nothing, Unit]

    Permalink

    A version of checkAllM that accepts four random variables.

    A version of checkAllM that accepts four random variables.

    Definition Classes
    CheckVariants
  31. final def checkAllM[R, A, B, C](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C])(test: (A, B, C) ⇒ ZIO[R, Nothing, TestResult]): ZTest[R, Nothing, Unit]

    Permalink

    A version of checkAllM that accepts three random variables.

    A version of checkAllM that accepts three random variables.

    Definition Classes
    CheckVariants
  32. final def checkAllM[R, A, B](rv1: Gen[R, A], rv2: Gen[R, B])(test: (A, B) ⇒ ZIO[R, Nothing, TestResult]): ZTest[R, Nothing, Unit]

    Permalink

    A version of checkAllM that accepts two random variables.

    A version of checkAllM that accepts two random variables.

    Definition Classes
    CheckVariants
  33. final def checkAllM[R, A](rv: Gen[R, A])(test: (A) ⇒ ZIO[R, Nothing, TestResult]): ZTest[R, Nothing, Unit]

    Permalink

    Checks the effectual test passes for all values from the given random variable.

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

    Definition Classes
    CheckVariants
  34. final def checkM[R, A, B, C, D](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C], rv4: Gen[R, D])(test: (A, B, C, D) ⇒ ZIO[R, Nothing, TestResult]): ZTest[R, Nothing, Unit]

    Permalink

    A version of checkM that accepts four random variables.

    A version of checkM that accepts four random variables.

    Definition Classes
    CheckVariants
  35. final def checkM[R, A, B, C](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C])(test: (A, B, C) ⇒ ZIO[R, Nothing, TestResult]): ZTest[R, Nothing, Unit]

    Permalink

    A version of checkM that accepts three random variables.

    A version of checkM that accepts three random variables.

    Definition Classes
    CheckVariants
  36. final def checkM[R, A, B](rv1: Gen[R, A], rv2: Gen[R, B])(test: (A, B) ⇒ ZIO[R, Nothing, TestResult]): ZTest[R, Nothing, Unit]

    Permalink

    A version of checkM that accepts two random variables.

    A version of checkM that accepts two random variables.

    Definition Classes
    CheckVariants
  37. final def checkM[R, A](rv: Gen[R, A])(test: (A) ⇒ ZIO[R, Nothing, TestResult]): ZTest[R, Nothing, Unit]

    Permalink

    Checks the effectual test passes for "sufficient" numbers of samples from the given random variable.

    Checks the effectual test passes for "sufficient" numbers of samples from the given random variable.

    Definition Classes
    CheckVariants
  38. final def checkSome[R, A, B, C, D](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C], rv4: Gen[R, D])(n: Int)(test: (A, B, C, D) ⇒ TestResult): ZTest[R, Nothing, Unit]

    Permalink

    A version of checkSome that accepts four random variables.

    A version of checkSome that accepts four random variables.

    Definition Classes
    CheckVariants
  39. final def checkSome[R, A, B, C](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C])(n: Int)(test: (A, B, C) ⇒ TestResult): ZTest[R, Nothing, Unit]

    Permalink

    A version of checkSome that accepts three random variables.

    A version of checkSome that accepts three random variables.

    Definition Classes
    CheckVariants
  40. final def checkSome[R, A, B](rv1: Gen[R, A], rv2: Gen[R, B])(n: Int)(test: (A, B) ⇒ TestResult): ZTest[R, Nothing, Unit]

    Permalink

    A version of checkSome that accepts two random variables.

    A version of checkSome that accepts two random variables.

    Definition Classes
    CheckVariants
  41. final def checkSome[R, A](rv: Gen[R, A])(n: Int)(test: (A) ⇒ TestResult): ZTest[R, Nothing, Unit]

    Permalink

    Checks the test passes for the specified number of samples from the given random variable.

    Checks the test passes for the specified number of samples from the given random variable.

    Definition Classes
    CheckVariants
  42. final def checkSomeM[R, A, B, C, D](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C], rv4: Gen[R, D])(n: Int)(test: (A, B, C, D) ⇒ ZIO[R, Nothing, TestResult]): ZTest[R, Nothing, Unit]

    Permalink

    A version of checkSomeM that accepts four random variables.

    A version of checkSomeM that accepts four random variables.

    Definition Classes
    CheckVariants
  43. final def checkSomeM[R, A, B, C](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C])(n: Int)(test: (A, B, C) ⇒ ZIO[R, Nothing, TestResult]): ZTest[R, Nothing, Unit]

    Permalink

    A version of checkSomeM that accepts three random variables.

    A version of checkSomeM that accepts three random variables.

    Definition Classes
    CheckVariants
  44. final def checkSomeM[R, A, B](rv1: Gen[R, A], rv2: Gen[R, B])(n: Int)(test: (A, B) ⇒ ZIO[R, Nothing, TestResult]): ZTest[R, Nothing, Unit]

    Permalink

    A version of checkSomeM that accepts two random variables.

    A version of checkSomeM that accepts two random variables.

    Definition Classes
    CheckVariants
  45. final def checkSomeM[R, A](rv: Gen[R, A])(n: Int)(test: (A) ⇒ ZIO[R, Nothing, TestResult]): ZTest[R, Nothing, Unit]

    Permalink

    Checks the effectual test passes for the specified number of samples from the given random variable.

    Checks the effectual test passes for the specified number of samples from the given random variable.

    Definition Classes
    CheckVariants
  46. val defaultTestRunner: TestRunner[String, ZTest[MockEnvironment, Any, Any], Any, Any]

    Permalink
  47. final def fail[E](cause: Cause[E]): ZTest[Any, E, Nothing]

    Permalink

    Creates a failed test result with the specified runtime cause.

  48. final val ignore: ZTest[Any, Nothing, Nothing]

    Permalink

    Creates an ignored test result.

  49. package mock

    Permalink
  50. final def platformSpecific[R, E, A, S](js: ⇒ A, jvm: ⇒ A)(f: (A) ⇒ ZTest[R, E, S]): ZTest[R, E, S]

    Permalink

    Passes platform specific information to the specified function, which will use that information to create a test.

    Passes platform specific information to the specified function, which will use that information to create a test. If the platform is neither ScalaJS nor the JVM, an ignored test result will be returned.

  51. package reflect

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

    Permalink

    Builds a suite containing a number of other specs.

  53. final def test[L](label: L)(assertion: ⇒ TestResult): ZSpec[Any, Nothing, L, Unit]

    Permalink

    Builds a spec with a single pure test.

  54. final def testM[R, L, T](label: L)(assertion: ZIO[R, Nothing, TestResult]): ZSpec[R, Nothing, L, Unit]

    Permalink

    Builds a spec with a single effectful test.

Inherited from CheckVariants

Inherited from AnyRef

Inherited from Any

Ungrouped