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()
- type AssertResult = BoolAlgebra[AssertionValue]
-
class
Assertion[-A] extends (⇒ A) ⇒ AssertResult
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
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. -
sealed
trait
BoolAlgebra[+A] extends Product with Serializable
A
BoolAlgebra[A]
is a description of logical operations on values of typeA
. - trait CheckVariants extends AnyRef
-
abstract
class
DefaultRunnableSpec extends RunnableSpec[TestEnvironment, String, Either[TestFailure[Nothing], TestSuccess[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[Any, Nothing, L, Either[TestFailure[E], TestSuccess[S]]]
An
ExecutedSpec
is a spec that has been run to produce test results. - sealed trait ExecutionStrategy extends AnyRef
-
final
case class
FailureDetails(fragment: AssertionValue, whole: AssertionValue, gen: Option[GenFailureDetails] = None) extends Product with Serializable
FailureDetails
keeps track of details relevant to failures. - trait FunctionVariants extends AnyRef
-
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. -
sealed
trait
GenFailureDetails extends AnyRef
GenFailureDetails
keeps track of relevant information related to a failure in a generative test. - trait GenZIO extends AnyRef
- case class RenderedResult(caseType: CaseType, label: String, status: Status, offset: Int, rendered: Seq[String]) extends Product with Serializable
-
abstract
class
RunnableSpec[R, L, T, E, S] extends AbstractRunnableSpec
A
RunnableSpec
has 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[-R, +E, +L, +T](caseValue: SpecCase[R, E, L, T, Spec[R, E, L, T]]) extends Product with Serializable
A
Spec[R, E, L, T]
is the backbone of _ZIO Test_.A
Spec[R, E, 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
, require an environment of typeR
and may potentially fail with an error of typeE
. -
final
class
TestAnnotation[V] extends AnyRef
A type of annotation.
-
class
TestAnnotationMap extends AnyRef
An annotation map keeps track of annotations of different types.
- case class TestArgs(testSearchTerm: Option[String]) extends Product with Serializable
-
trait
TestAspect[+LowerR, -UpperR, +LowerE, -UpperE, +LowerS, -UpperS] 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, error, or success type. -
type
TestAspectPoly = TestAspect[Nothing, Any, Nothing, Any, Nothing, Any]
A
TestAspectPoly
is aTestAspect
that is completely polymorphic, having no requirements on error or environment. -
type
TestExecutor[+R, L, -T, E, +S] = (Spec[R, E, L, T], ExecutionStrategy) ⇒ UIO[ExecutedSpec[L, E, S]]
A
TestExecutor[R, L, T, E, S]
is capable of executing specs containing tests of typeT
, annotated with labels of typeL
, that require an environmentR
and may fail with anE
or 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 = BoolAlgebra[FailureDetails]
-
case class
TestRunner[R, L, -T, E, S](executor: TestExecutor[R, L, T, E, S], platform: Platform = ..., 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 environmentR
and may fail with an errorE
or succeed with anS
, using labels of typeL
.A
TestRunner[R, E, L, S]
encapsulates all the logic necessary to run specs that require an environmentR
and may fail with an errorE
or succeed with anS
, using labels of typeL
. Test runners require a test executor, a platform, and a reporter. - sealed trait TestSuccess[+S] extends AnyRef
- final case class TestTimeoutException(message: String) extends Throwable with Product with Serializable
- trait TimeoutVariants extends AnyRef
-
type
ZSpec[-R, +E, +L, +S] = Spec[R, E, L, Either[TestFailure[Nothing], TestSuccess[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, E, Either[TestFailure[Nothing], TestSuccess[S]]]
A
ZTest[R, E, S]
is an effectfully produced test that requires anR
and may fail with anE
or 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, E, A](value: ZIO[R, E, A], assertion: Assertion[A]): ZIO[R, E, TestResult]
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): ZIO[R, Nothing, TestResult]
A version of
check
that accepts four random variables.A version of
check
that 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): ZIO[R, Nothing, TestResult]
A version of
check
that accepts three random variables.A version of
check
that 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): ZIO[R, Nothing, TestResult]
A version of
check
that accepts two random variables.A version of
check
that accepts two random variables.- Definition Classes
- CheckVariants
-
final
def
check[R, A](rv: Gen[R, A])(test: (A) ⇒ TestResult): ZIO[R, Nothing, TestResult]
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): ZIO[R, Nothing, TestResult]
A version of
checkAll
that accepts four random variables.A version of
checkAll
that 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): ZIO[R, Nothing, TestResult]
A version of
checkAll
that accepts three random variables.A version of
checkAll
that 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): ZIO[R, Nothing, TestResult]
A version of
checkAll
that accepts two random variables.A version of
checkAll
that accepts two random variables.- Definition Classes
- CheckVariants
-
final
def
checkAll[R, A](rv: Gen[R, A])(test: (A) ⇒ TestResult): ZIO[R, Nothing, TestResult]
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
-
final
def
checkAllM[R, E, 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, E, TestResult]): ZIO[R, E, TestResult]
A version of
checkAllM
that accepts four random variables.A version of
checkAllM
that accepts four random variables.- Definition Classes
- CheckVariants
-
final
def
checkAllM[R, E, A, B, C](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C])(test: (A, B, C) ⇒ ZIO[R, E, TestResult]): ZIO[R, E, TestResult]
A version of
checkAllM
that accepts three random variables.A version of
checkAllM
that accepts three random variables.- Definition Classes
- CheckVariants
-
final
def
checkAllM[R, E, A, B](rv1: Gen[R, A], rv2: Gen[R, B])(test: (A, B) ⇒ ZIO[R, E, TestResult]): ZIO[R, E, TestResult]
A version of
checkAllM
that accepts two random variables.A version of
checkAllM
that accepts two random variables.- Definition Classes
- CheckVariants
-
final
def
checkAllM[R, E, A](rv: Gen[R, A])(test: (A) ⇒ ZIO[R, E, TestResult]): ZIO[R, E, TestResult]
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
-
final
def
checkM[R, E, 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, E, TestResult]): ZIO[R, E, TestResult]
A version of
checkM
that accepts four random variables.A version of
checkM
that accepts four random variables.- Definition Classes
- CheckVariants
-
final
def
checkM[R, E, A, B, C](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C])(test: (A, B, C) ⇒ ZIO[R, E, TestResult]): ZIO[R, E, TestResult]
A version of
checkM
that accepts three random variables.A version of
checkM
that accepts three random variables.- Definition Classes
- CheckVariants
-
final
def
checkM[R, E, A, B](rv1: Gen[R, A], rv2: Gen[R, B])(test: (A, B) ⇒ ZIO[R, E, TestResult]): ZIO[R, E, TestResult]
A version of
checkM
that accepts two random variables.A version of
checkM
that accepts two random variables.- Definition Classes
- CheckVariants
-
final
def
checkM[R, E, A](rv: Gen[R, A])(test: (A) ⇒ ZIO[R, E, TestResult]): ZIO[R, E, TestResult]
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): ZIO[R, Nothing, TestResult]
A version of
checkSome
that accepts four random variables.A version of
checkSome
that 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): ZIO[R, Nothing, TestResult]
A version of
checkSome
that accepts three random variables.A version of
checkSome
that 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): ZIO[R, Nothing, TestResult]
A version of
checkSome
that accepts two random variables.A version of
checkSome
that accepts two random variables.- Definition Classes
- CheckVariants
-
final
def
checkSome[R, A](rv: Gen[R, A])(n: Int)(test: (A) ⇒ TestResult): ZIO[R, Nothing, TestResult]
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, E, 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, E, TestResult]): ZIO[R, E, TestResult]
A version of
checkSomeM
that accepts four random variables.A version of
checkSomeM
that accepts four random variables.- Definition Classes
- CheckVariants
-
final
def
checkSomeM[R, E, A, B, C](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C])(n: Int)(test: (A, B, C) ⇒ ZIO[R, E, TestResult]): ZIO[R, E, TestResult]
A version of
checkSomeM
that accepts three random variables.A version of
checkSomeM
that accepts three random variables.- Definition Classes
- CheckVariants
-
final
def
checkSomeM[R, E, A, B](rv1: Gen[R, A], rv2: Gen[R, B])(n: Int)(test: (A, B) ⇒ ZIO[R, E, TestResult]): ZIO[R, E, TestResult]
A version of
checkSomeM
that accepts two random variables.A version of
checkSomeM
that accepts two random variables.- Definition Classes
- CheckVariants
-
final
def
checkSomeM[R, E, A](rv: Gen[R, A])(n: Int)(test: (A) ⇒ ZIO[R, E, TestResult]): ZIO[R, E, TestResult]
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[TestEnvironment, String, Either[TestFailure[Nothing], TestSuccess[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[R, E, L, T](label: L)(specs: Spec[R, E, L, T]*): Spec[R, E, 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, E, L](label: L)(assertion: ZIO[R, E, TestResult]): ZSpec[R, E, L, Unit]
Builds a spec with a single effectful test.
- object Assertion
- object AssertionValue
- object BoolAlgebra extends Serializable
- object DefaultTestReporter
-
object
DefaultTestRunner extends TestRunner[TestEnvironment, String, Either[TestFailure[Nothing], TestSuccess[Any]], Any, Any]
A
Runner
that provides a default testable environment. - object ExecutionStrategy
- object Gen extends GenZIO with FunctionVariants with Serializable
- object GenFailureDetails
- object RenderedResult extends Serializable
- object Sample extends Serializable
- object Sized
- object Spec extends Serializable
- object SummaryBuilder
- object TestAnnotation
- object TestAnnotationMap
- object TestArgs extends Serializable
- object TestAspect extends TimeoutVariants
- object TestExecutor
- object TestFailure
- object TestLogger
-
object
TestPlatform
TestPlatform
provides information about the platform tests are being run on to enable platform specific test configuration. - object TestReporter
- object TestSuccess