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)) } } }
- Alphabetic
- By Inheritance
- test
- CheckVariants
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
- abstract class AbstractRunnableSpec extends AnyRef
- Annotations
- @EnableReflectiveInstantiation()
- sealed trait AssertResult[+A] extends Product with Serializable
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. - class Assertion[-A] extends (=> A) => AssertResult[Either[AssertionValue, Unit]]
An
Assertion[A]is capable of producing assertion results on anA.An
Assertion[A]is capable of producing assertion results on anA. As a proposition, assertions compose using logical conjuction and disjunction, and can be negated. - sealed trait AssertionValue extends AnyRef
An
AssertionValuekeeps track of a assertion and a value, existentially hiding the type.An
AssertionValuekeeps 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. - trait CheckVariants extends AnyRef
- abstract class DefaultRunnableSpec extends RunnableSpec[String, ZTest[MockEnvironment, Any, Any], Any, Any]
A default runnable spec that provides testable versions of all of the modules in ZIO (Clock, Random, etc).
- type ExecutedSpec[+L, +E, +S] = Spec[L, Either[TestFailure[E], TestSuccess[S]]]
An
ExecutedSpecis a spec that has been run to produce test results. - sealed trait ExecutionStrategy extends AnyRef
- final case class FailureDetails(fragment: AssertionValue, whole: AssertionValue) extends Product with Serializable
FailureDetailskeeps track of details relevant to failures. - 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 typeA, which requires an environmentR.A
Gen[R, A]represents a generator of values of typeA, which requires an environmentR. Generators may be random or deterministic. - case class RenderedResult(caseType: CaseType, label: String, status: Status, offset: Int, rendered: Seq[String]) extends Product with Serializable
- abstract class RunnableSpec[L, T, E, S] extends AbstractRunnableSpec
A
RunnableSpechas a main function and can be run by the JVM / Scala.js. - final case class Sample[-R, +A](value: A, shrink: ZStream[R, Nothing, Sample[R, A]]) extends Product with Serializable
A sample is a single observation from a random variable, together with a tree of "shrinkings" used for minimization of "large" failures.
- trait Sized extends AnyRef
- 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 typeT. All specs are annotated with labels of typeL. - trait TestAspect[+LowerR, -UpperR, +LowerE, -UpperE, +LowerS, -UpperS] extends AnyRef
A
TestAspectis an aspect that can be weaved into specs.A
TestAspectis 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. - type TestAspectPoly = TestAspect[Nothing, Any, Nothing, Any, Nothing, Any]
A
TestAspectPolyis aTestAspectthat is completely polymorphic, having no requirements on error or environment. - type TestExecutor[L, -T, +E, +S] = (Spec[L, T], ExecutionStrategy) => UIO[ExecutedSpec[L, E, S]]
A
TestExecutor[L, T, E, S]is capable of executing specs containing tests of typeT, annotated with labels of typeL, that may fail with anEor succeed with aS. - sealed trait TestFailure[+E] extends AnyRef
- trait TestLogger extends AnyRef
- type TestReporter[-L, -E, -S] = (Duration, ExecutedSpec[L, E, S]) => URIO[TestLogger, Unit]
A
TestReporter[L, E, S]is capable of reporting test results annotated with labelsL, error typeE, and success typeS. - type TestResult = AssertResult[Either[FailureDetails, Unit]]
- case class TestRunner[L, -T, E, S](executor: TestExecutor[L, T, E, S], platform: Platform = PlatformLive.makeDefault().withReportFailure(_ => ()), reporter: TestReporter[L, E, S] = DefaultTestReporter()) extends Product with Serializable
A
TestRunner[R, E, L, S]encapsulates all the logic necessary to run specs that require an environmentRand may fail with an errorEor succeed with anS, using labels of typeL.A
TestRunner[R, E, L, S]encapsulates all the logic necessary to run specs that require an environmentRand may fail with an errorEor succeed with anS, using labels of typeL. Test runners require a test executor, a platform, and a reporter. - sealed trait TestSuccess[+S] extends AnyRef
- trait TimeoutStrategy extends AnyRef
A
TimeoutStrategyadds logic to aZSpecto handle long-running and potentially non-terminating tests. - type ZSpec[-R, +E, +L, +S] = Spec[L, ZTest[R, E, S]]
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 anR, might fail with anE, might succeed with anS, and whose nodes are annotated with labelsL. - implicit class ZSpecSyntax[R, E, L, S] extends AnyRef
Adds syntax for adding aspects.
Adds syntax for adding aspects.
test("foo") { assert(42, equalTo(42)) } @@ ignore
- type ZTest[-R, +E, +S] = ZIO[R, TestFailure[E], TestSuccess[S]]
A
ZTest[R, E, S]is an effectfully produced test that requires anRand may fail with anEor succeed with aS.
Value Members
- final def assert[A](value: => A, assertion: Assertion[A]): TestResult
Checks the assertion holds for the given value.
- final def assertM[R, A](value: ZIO[R, Nothing, A], assertion: Assertion[A]): ZTest[R, Nothing, Unit]
Checks the assertion holds for the given effectfully-computed value.
- 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]
A version of
checkthat accepts four random variables.A version of
checkthat accepts four random variables.- Definition Classes
- CheckVariants
- 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]
A version of
checkthat accepts three random variables.A version of
checkthat accepts three random variables.- Definition Classes
- CheckVariants
- final def check[R, A, B](rv1: Gen[R, A], rv2: Gen[R, B])(test: (A, B) => TestResult): ZTest[R, Nothing, Unit]
A version of
checkthat accepts two random variables.A version of
checkthat accepts two random variables.- Definition Classes
- CheckVariants
- final def check[R, A](rv: Gen[R, A])(test: (A) => TestResult): ZTest[R, Nothing, Unit]
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
- 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]
A version of
checkAllthat accepts four random variables.A version of
checkAllthat accepts four random variables.- Definition Classes
- CheckVariants
- 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]
A version of
checkAllthat accepts three random variables.A version of
checkAllthat accepts three random variables.- Definition Classes
- CheckVariants
- final def checkAll[R, A, B](rv1: Gen[R, A], rv2: Gen[R, B])(test: (A, B) => TestResult): ZTest[R, Nothing, Unit]
A version of
checkAllthat accepts two random variables.A version of
checkAllthat accepts two random variables.- Definition Classes
- CheckVariants
- final def checkAll[R, A](rv: Gen[R, A])(test: (A) => TestResult): ZTest[R, Nothing, Unit]
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
Genthat comprehensively explore all possibilities in a given domain.- Definition Classes
- CheckVariants
- 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]
A version of
checkAllMthat accepts four random variables.A version of
checkAllMthat accepts four random variables.- Definition Classes
- CheckVariants
- 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]
A version of
checkAllMthat accepts three random variables.A version of
checkAllMthat accepts three random variables.- Definition Classes
- CheckVariants
- 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]
A version of
checkAllMthat accepts two random variables.A version of
checkAllMthat accepts two random variables.- Definition Classes
- CheckVariants
- final def checkAllM[R, A](rv: Gen[R, A])(test: (A) => ZIO[R, Nothing, TestResult]): ZTest[R, Nothing, Unit]
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
Genthat comprehensively explore all possibilities in a given domain.- Definition Classes
- CheckVariants
- 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]
A version of
checkMthat accepts four random variables.A version of
checkMthat accepts four random variables.- Definition Classes
- CheckVariants
- 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]
A version of
checkMthat accepts three random variables.A version of
checkMthat accepts three random variables.- Definition Classes
- CheckVariants
- 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]
A version of
checkMthat accepts two random variables.A version of
checkMthat accepts two random variables.- Definition Classes
- CheckVariants
- final def checkM[R, A](rv: Gen[R, A])(test: (A) => ZIO[R, Nothing, TestResult]): ZTest[R, Nothing, Unit]
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
- 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]
A version of
checkSomethat accepts four random variables.A version of
checkSomethat accepts four random variables.- Definition Classes
- CheckVariants
- 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]
A version of
checkSomethat accepts three random variables.A version of
checkSomethat accepts three random variables.- Definition Classes
- CheckVariants
- final def checkSome[R, A, B](rv1: Gen[R, A], rv2: Gen[R, B])(n: Int)(test: (A, B) => TestResult): ZTest[R, Nothing, Unit]
A version of
checkSomethat accepts two random variables.A version of
checkSomethat accepts two random variables.- Definition Classes
- CheckVariants
- final def checkSome[R, A](rv: Gen[R, A])(n: Int)(test: (A) => TestResult): ZTest[R, Nothing, Unit]
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
- 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]
A version of
checkSomeMthat accepts four random variables.A version of
checkSomeMthat accepts four random variables.- Definition Classes
- CheckVariants
- 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]
A version of
checkSomeMthat accepts three random variables.A version of
checkSomeMthat accepts three random variables.- Definition Classes
- CheckVariants
- 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]
A version of
checkSomeMthat accepts two random variables.A version of
checkSomeMthat accepts two random variables.- Definition Classes
- CheckVariants
- final def checkSomeM[R, A](rv: Gen[R, A])(n: Int)(test: (A) => ZIO[R, Nothing, TestResult]): ZTest[R, Nothing, Unit]
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
- val defaultTestRunner: TestRunner[String, ZTest[MockEnvironment, Any, Any], Any, Any]
- final def fail[E](cause: Cause[E]): ZTest[Any, E, Nothing]
Creates a failed test result with the specified runtime cause.
- final val ignore: ZTest[Any, Nothing, Nothing]
Creates an ignored test result.
- final def platformSpecific[R, E, A, S](js: => A, jvm: => A)(f: (A) => ZTest[R, E, S]): ZTest[R, E, S]
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.
- final def suite[L, T](label: L)(specs: Spec[L, T]*): Spec[L, T]
Builds a suite containing a number of other specs.
- final def test[L](label: L)(assertion: => TestResult): ZSpec[Any, Nothing, L, Unit]
Builds a spec with a single pure test.
- final def testM[R, L, T](label: L)(assertion: ZIO[R, Nothing, TestResult]): ZSpec[R, Nothing, L, Unit]
Builds a spec with a single effectful test.
- object AssertResult extends Serializable
- object Assertion
- object AssertionValue
- object DefaultTestReporter
- object DefaultTestRunner extends TestRunner[String, ZTest[MockEnvironment, Any, Any], Any, Any]
A
Runnerthat provides a default testable environment. - object ExecutionStrategy
- object Gen extends Serializable
- object RenderedResult extends Serializable
- object Sample extends Serializable
- object Sized
- object Spec extends Serializable
- object TestAspect
- object TestExecutor
- object TestFailure
- object TestLogger
- object TestPlatform
TestPlatformprovides information about the platform tests are being run on to enable platform specific test configuration. - object TestReporter
- object TestSuccess
- object TimeoutStrategy