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 { def spec = suite("clock")( test("time is non-zero") { for { time <- Live.live(nanoTime) } yield assertTrue(time >= 0) } ) }
- Alphabetic
- By Inheritance
- test
- CompileVariants
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Package Members
- package diff
- package internal
- package laws
The
lawspackage provides functionality for describing laws as values.The
lawspackage provides functionality for describing laws as values. The fundamental abstraction is a set ofZLaws[Caps, R]. These laws model the laws that instances having a capability of typeCapsare expected to satisfy. A capabilityCaps[_]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:
- Reflexivity -
a1 === a1 - Symmetry -
a1 === a2 ==> a2 === a1 - 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
ZLawsconstructors. 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
runmethod that takes a generator of values of typeAand checks that those values satisfy the laws. In addition, objects can extendZLawfulto 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.int)
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.
- Reflexivity -
- package poly
- package render
Type Members
- abstract class AbstractRunnableSpec extends AnyRef
- Annotations
- @EnableReflectiveInstantiation()
- type Annotated[+A] = (A, TestAnnotationMap)
An
Annotated[A]contains a value of typeAalong with zero or more test annotations. - trait Annotations extends Serializable
The
Annotationstrait provides access to an annotation map that tests can add arbitrary annotations to.The
Annotationstrait provides access to an annotation map that tests can add arbitrary annotations to. Each annotation consists of a string identifier, an initial value, and a function for combining two values. Annotations form monoids and you can think ofAnnotationsas a more structured logging service or as a super polymorphic version of the writer monad effect. - case class Assert(arrow: TestArrow[Any, Boolean]) extends Product with Serializable
- type AssertResult = BoolAlgebra[AssertionValue]
- type AssertResultM = BoolAlgebraM[Any, Nothing, AssertionValue]
- final class Assertion[-A] extends AssertionM[A] with (=> 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 conjunction and disjunction, and can be negated. - sealed abstract class AssertionData extends AnyRef
- abstract class AssertionM[-A] extends AnyRef
An
AssertionM[A]is capable of producing assertion results on anA.An
AssertionM[A]is capable of producing assertion results on anA. As a proposition, assertions compose using logical conjunction and disjunction, and can be negated. - sealed abstract class AssertionMData extends AnyRef
- sealed trait AssertionResult extends AnyRef
- sealed abstract class 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 AssertionVariants extends AnyRef
- sealed abstract class BoolAlgebra[+A] extends Product with Serializable
A
BoolAlgebra[A]is a description of logical operations on values of typeA. - final case class BoolAlgebraM[-R, +E, +A](run: ZIO[R, E, BoolAlgebra[A]]) extends Product with Serializable
- trait CheckConstructor[Environment, In] extends AnyRef
- trait CheckConstructorLowPriority1 extends CheckConstructorLowPriority2
- trait CheckConstructorLowPriority2 extends CheckConstructorLowPriority3
- trait CheckConstructorLowPriority3 extends CheckConstructorLowPriority4
- trait CheckConstructorLowPriority4 extends CheckConstructorLowPriority5
- trait CheckConstructorLowPriority5 extends CheckConstructorLowPriority6
- trait CheckConstructorLowPriority6 extends CheckConstructorLowPriority7
- trait CheckConstructorLowPriority7 extends AnyRef
- trait CompileVariants extends AnyRef
- final class CustomAssertion[A, B] extends AnyRef
CustomAssertion allows users to create their own custom assertions for use in
assertTrue.CustomAssertion allows users to create their own custom assertions for use in
assertTrue. They are constructed withCustomAssertion.make.// Definition sealed trait Pet case class Dog(hasBone: Boolean) extends Pet case class Fish(bubbles: Double) extends Pet case class Cat(livesRemaining: Int) extends Color val lives = CustomAssertion.make[Pet] { case Cat(livesRemaining) => Right(livesRemaining) case other => Left(s"Expected $$other to be Cat") } // Usage suite("custom assertions")( test("as even") { val pet: Option[Pet] = Some(Cat(8)) assertTrue(pet.is(_.some.custom(lives)) == 8) } )
- abstract class DefaultRunnableSpec extends RunnableSpec[TestEnvironment, Any]
A default runnable spec that provides testable versions of all of the modules in ZIO (Clock, Random, etc).
- sealed abstract class Eql[A, B] extends AnyRef
A value of type
Eql[A, B]provides implicit evidence that two values with typesAandBcould potentially be equal, that is, thatAis a subtype ofBorBis a subtype ofA.A value of type
Eql[A, B]provides implicit evidence that two values with typesAandBcould potentially be equal, that is, thatAis a subtype ofBorBis a subtype ofA.- Annotations
- @implicitNotFound()
- sealed trait ErrorMessage extends AnyRef
- final case class ExecutedSpec[+E](caseValue: SpecCase[E, ExecutedSpec[E]]) extends Product with Serializable
An
ExecutedSpecis a spec that has been run to produce test results. - case class FailureCase(errorMessage: Message, codeString: String, location: String, path: Chunk[(String, Any)], span: Span, nestedFailures: Chunk[FailureCase], result: Any) extends Product with Serializable
- final case class FailureDetails(assertion: ::[AssertionValue]) extends Product with Serializable
FailureDetailskeeps track of details relevant to failures. - trait FunctionVariants extends AnyRef
- final case class Gen[-R, +A](sample: ZStream[R, Nothing, Option[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 abstract class GenFailureDetails extends AnyRef
GenFailureDetailskeeps track of relevant information related to a failure in a generative test. - trait GenZIO extends AnyRef
- trait Live extends AnyRef
The
Livetrait provides access to the "live" environment from within the test environment for effects such as printing test results to the console or timing out tests where it is necessary to access the real environment.The
Livetrait provides access to the "live" environment from within the test environment for effects such as printing test results to the console or timing out tests where it is necessary to access the real environment.The easiest way to access the "live" environment is to use the
livemethod with an effect that would otherwise access the test environment.import zio.Clock import zio.test._ val realTime = live(Clock.nanoTime)
The
withLivemethod can be used to apply a transformation to an effect with the live environment while ensuring that the effect itself still runs with the test environment, for example to time out a test. Both of these methods are re-exported in theenvironmentpackage for easy availability. - trait PrettyPrintVersionSpecific extends AnyRef
- trait Restorable extends Serializable
- sealed trait Result[+A] extends AnyRef
- abstract class RunnableSpec[R, E] 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, Option[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 Serializable
- class SmartAssertMacros extends AnyRef
- implicit final class SmartAssertionOps[A] extends AnyVal
- final case class Spec[-R, +E, +T](caseValue: SpecCase[R, E, T, Spec[R, E, T]]) extends SpecVersionSpecific[R, E, T] with Product with Serializable
A
Spec[R, E, T]is the backbone of _ZIO Test_.A
Spec[R, E, T]is the backbone of _ZIO Test_. Every spec is either a suite, which contains other specs, or a test of typeT. All specs require an environment of typeRand may potentially fail with an error of typeE. - class SpecLayerMacros extends LayerMacroUtils
- trait SuiteConstructor[In] extends AnyRef
- trait SuiteConstructorLowPriority1 extends SuiteConstructorLowPriority2
- trait SuiteConstructorLowPriority2 extends SuiteConstructorLowPriority3
- trait SuiteConstructorLowPriority3 extends SuiteConstructorLowPriority4
- trait SuiteConstructorLowPriority4 extends AnyRef
- final case class Summary(success: Int, fail: Int, ignore: Int, summary: String) extends Product with Serializable
- final class TestAnnotation[V] extends Serializable
A type of annotation.
- final class TestAnnotationMap extends AnyRef
An annotation map keeps track of annotations of different types.
- sealed abstract class TestAnnotationRenderer extends AnyRef
A
TestAnnotationRendererknows how to render test annotations. - final case class TestArgs(testSearchTerms: List[String], tagSearchTerms: List[String], testTaskPolicy: Option[String], testRenderer: Option[String], printSummary: Boolean) extends Product with Serializable
- sealed trait TestArrow[-A, +B] extends AnyRef
- abstract class TestAspect[+LowerR, -UpperR, +LowerE, -UpperE] 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 or error type. - type TestAspectAtLeastR[-R] = TestAspect[Nothing, R, Nothing, Any]
A
TestAspectAtLeast[R]is aTestAspectthat requires at least anRin its environment. - type TestAspectPoly = TestAspect[Nothing, Any, Nothing, Any]
A
TestAspectPolyis aTestAspectthat is completely polymorphic, having no requirements on error or environment. - trait TestClock extends Clock with Restorable
TestClockmakes it easy to deterministically and efficiently test effects involving the passage of time.TestClockmakes it easy to deterministically and efficiently test effects involving the passage of time.Instead of waiting for actual time to pass,
sleepand methods implemented in terms of it schedule effects to take place at a given clock time. Users can adjust the clock time using theadjustandsetTimemethods, and all effects scheduled to take place on or before that time will automatically be run in order.For example, here is how we can test
ZIO#timeoutusingTestClock:import zio.ZIO import zio.test.TestClock for { fiber <- ZIO.sleep(5.minutes).timeout(1.minute).fork _ <- TestClock.adjust(1.minute) result <- fiber.join } yield result == None
Note how we forked the fiber that
sleepwas invoked on. Calls tosleepand methods derived from it will semantically block until the time is set to on or after the time they are scheduled to run. If we didn't fork the fiber on which we called sleep we would never get to set the time on the line below. Thus, a useful pattern when usingTestClockis to fork the effect being tested, then adjust the clock time, and finally verify that the expected effects have been performed.For example, here is how we can test an effect that recurs with a fixed delay:
import zio.Queue import zio.test.TestClock for { q <- Queue.unbounded[Unit] _ <- q.offer(()).delay(60.minutes).forever.fork a <- q.poll.map(_.isEmpty) _ <- TestClock.adjust(60.minutes) b <- q.take.as(true) c <- q.poll.map(_.isEmpty) _ <- TestClock.adjust(60.minutes) d <- q.take.as(true) e <- q.poll.map(_.isEmpty) } yield a && b && c && d && e
Here we verify that no effect is performed before the recurrence period, that an effect is performed after the recurrence period, and that the effect is performed exactly once. The key thing to note here is that after each recurrence the next recurrence is scheduled to occur at the appropriate time in the future, so when we adjust the clock by 60 minutes exactly one value is placed in the queue, and when we adjust the clock by another 60 minutes exactly one more value is placed in the queue.
- trait TestClockPlatformSpecific extends AnyRef
- trait TestConfig extends Serializable
The
TestConfigservice provides access to default configuration settings used by ZIO Test, including the number of times to repeat tests to ensure they are stable, the number of times to retry flaky tests, the sufficient number of samples to check from a random variable, and the maximum number of shrinkings to minimize large failures. - trait TestConsole extends Console with Restorable
TestConsoleprovides a testable interface for programs interacting with the console by modeling input and output as reading from and writing to input and output buffers maintained byTestConsoleand backed by aRef.TestConsoleprovides a testable interface for programs interacting with the console by modeling input and output as reading from and writing to input and output buffers maintained byTestConsoleand backed by aRef.All calls to
printandprintLineusing theTestConsolewill write the string to the output buffer and all calls toreadLinewill take a string from the input buffer. To facilitate debugging, by default output will also be rendered to standard output. You can enable or disable this for a scope usingdebug,silent, or the corresponding test aspects.TestConsolehas several methods to access and manipulate the content of these buffers includingfeedLinesto feed strings to the input buffer that will then be returned by calls toreadLine,outputto get the content of the output buffer from calls toprintandprintLine, andclearInputandclearOutputto clear the respective buffers.Together, these functions make it easy to test programs interacting with the console.
import zio.Console._ import zio.test.TestConsole import zio.ZIO val sayHello = for { name <- readLine _ <- printLine("Hello, " + name + "!") } yield () for { _ <- TestConsole.feedLines("John", "Jane", "Sally") _ <- ZIO.collectAll(List.fill(3)(sayHello)) result <- TestConsole.output } yield result == Vector("Hello, John!\n", "Hello, Jane!\n", "Hello, Sally!\n")
- trait TestConstructor[-Environment, In] extends AnyRef
- trait TestConstructorLowPriority1 extends TestConstructorLowPriority2
- trait TestConstructorLowPriority2 extends TestConstructorLowPriority3
- trait TestConstructorLowPriority3 extends TestConstructorLowPriority4
- trait TestConstructorLowPriority4 extends TestConstructorLowPriority5
- trait TestConstructorLowPriority5 extends TestConstructorLowPriority6
- trait TestConstructorLowPriority6 extends TestConstructorLowPriority7
- trait TestConstructorLowPriority7 extends AnyRef
- sealed trait TestDuration extends AnyRef
- type TestEnvironment = Annotations with Live with Sized with TestClock with TestConfig with TestConsole with TestRandom with TestSystem
- abstract class TestExecutor[+R, E] extends AnyRef
A
TestExecutor[R, E]is capable of executing specs that require an environmentRand may fail with anE. - sealed abstract class TestFailure[+E] extends AnyRef
- final case class TestLens[+A]() extends Product with Serializable
- implicit final class TestLensAnyOps[A] extends AnyVal
- implicit final class TestLensCauseOps[E] extends AnyVal
- implicit final class TestLensEitherOps[E, A] extends AnyVal
- implicit final class TestLensExitOps[E, A] extends AnyVal
- implicit final class TestLensOptionOps[A] extends AnyVal
- trait TestLogger extends Serializable
- trait TestRandom extends Random with Restorable
TestRandomallows for deterministically testing effects involving randomness.TestRandomallows for deterministically testing effects involving randomness.TestRandomoperates in two modes. In the first mode,TestRandomis a purely functional pseudo-random number generator. It will generate pseudo-random values just likescala.util.Randomexcept that no internal state is mutated. Instead, methods likenextIntdescribe state transitions from one random state to another that are automatically composed together through methods likeflatMap. The random seed can be set usingsetSeedandTestRandomis guaranteed to return the same sequence of values for any given seed. This is useful for deterministically generating a sequence of pseudo-random values and powers the property based testing functionality in ZIO Test.In the second mode,
TestRandommaintains an internal buffer of values that can be "fed" with methods such asfeedIntsand then when random values of that type are generated they will first be taken from the buffer. This is useful for verifying that functions produce the expected output for a given sequence of "random" inputs.import zio.Random import zio.test.TestRandom for { _ <- TestRandom.feedInts(4, 5, 2) x <- Random.nextIntBounded(6) y <- Random.nextIntBounded(6) z <- Random.nextIntBounded(6) } yield x + y + z == 11
TestRandomwill automatically take values from the buffer if a value of the appropriate type is available and otherwise generate a pseudo-random value, so there is nothing you need to do to switch between the two modes. Just generate random values as you normally would to get pseudo-random values, or feed in values of your own to get those values back. You can also use methods likeclearIntsto clear the buffer of values of a given type so you can fill the buffer with new values or go back to pseudo-random number generation. - type TestReporter[-E] = (zio.Duration, ExecutedSpec[E]) => URIO[TestLogger, Unit]
A
TestReporter[E]is capable of reporting test results with error typeE. - type TestResult = BoolAlgebra[AssertionResult]
- final case class TestRunner[R, E](executor: TestExecutor[R, E], runtimeConfig: RuntimeConfig = RuntimeConfig.makeDefault(), reporter: TestReporter[E] = DefaultTestReporter(TestRenderer.default, TestAnnotationRenderer.default)(ZTraceElement.empty), bootstrap: Layer[Nothing, TestLogger with Clock] = (Console.live.to(TestLogger.fromConsole(ZTraceElement.empty))(ZTraceElement.empty)) ++ Clock.live) extends Product with Serializable
A
TestRunner[R, E]encapsulates all the logic necessary to run specs that require an environmentRand may fail with an errorE.A
TestRunner[R, E]encapsulates all the logic necessary to run specs that require an environmentRand may fail with an errorE. Test runners require a test executor, a runtime configuration, and a reporter. - sealed abstract class TestSuccess extends AnyRef
- trait TestSystem extends System with Restorable
TestSystemsupports deterministic testing of effects involving system properties.TestSystemsupports deterministic testing of effects involving system properties. Internally,TestSystemmaintains mappings of environment variables and system properties that can be set and accessed. No actual environment variables or system properties will be accessed or set as a result of these actions.import zio.system import zio.test.TestSystem for { _ <- TestSystem.putProperty("java.vm.name", "VM") result <- system.property("java.vm.name") } yield result == Some("VM")
- final case class TestTimeoutException(message: String) extends Throwable with Product with Serializable
- trait TimeVariants extends AnyRef
- trait TimeoutVariants extends AnyRef
- sealed trait Trace[+A] extends AnyRef
- abstract class ZIOSpec[R] extends ZIOSpecAbstract
- abstract class ZIOSpecAbstract extends ZIOApp
- Annotations
- @EnableReflectiveInstantiation()
- abstract class ZIOSpecDefault extends ZIOSpec[TestEnvironment]
- type ZSpec[-R, +E] = Spec[R, TestFailure[E], TestSuccess]
A
ZSpec[R, E]is the canonical spec for testing ZIO programs.A
ZSpec[R, E]is the canonical spec for testing ZIO programs. The spec's test type is a ZIO effect that requires anRand might fail with anE. - type ZTest[-R, +E] = ZIO[R, TestFailure[E], TestSuccess]
A
ZTest[R, E]is an effectfully produced test that requires anRand may fail with anE. - type ZTestEnv = TestClock with TestConsole with TestRandom with TestSystem
A
ZRTestEnvis an alias for all ZIO provided Restorable TestEnvironment objects
Deprecated Type Members
- class DefaultMutableRunnableSpec extends MutableRunnableSpec[Any]
Syntax for writing test like
Syntax for writing test like
object MySpec extends DefaultMutableRunnableSpec { suite("foo") { test("name") { } @@ ignore test("name 2") } suite("another suite") { test("name 3") } }
- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use DefaultRunnableSpec
- class MutableRunnableSpec[R] extends RunnableSpec[TestEnvironment, Any]
Syntax for writing test like
Syntax for writing test like
object MySpec extends MutableRunnableSpec(layer, aspect) { suite("foo") { test("name") { } @@ ignore test("name 2") } suite("another suite") { test("name 3") } }
- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use RunnableSpec
Value Members
- macro def assert[A](expr: => A)(assertion: Assertion[A]): TestResult
Checks the assertion holds for the given value.
Checks the assertion holds for the given value.
- Definition Classes
- CompileVariants
- def assertCompletes(implicit trace: ZTraceElement): TestResult
Asserts that the given test was completed.
- def assertCompletesM(implicit trace: ZTraceElement): UIO[TestResult]
Asserts that the given test was completed.
- macro def assertM[R, E, A](effect: ZIO[R, E, A])(assertion: AssertionM[A]): ZIO[R, E, TestResult]
Checks the assertion holds for the given effectfully-computed value.
Checks the assertion holds for the given effectfully-computed value.
- Definition Classes
- CompileVariants
- def assertNever(message: String)(implicit trace: ZTraceElement): TestResult
Asserts that the given test was never completed.
- macro def assertTrue(expr: Boolean): Assert
- Definition Classes
- CompileVariants
- macro def assertTrue(expr: Boolean, exprs: Boolean*): Assert
Checks the assertion holds for the given value.
Checks the assertion holds for the given value.
- Definition Classes
- CompileVariants
- def check[R <: TestConfig, A, B, C, D, F, G, In](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C], rv4: Gen[R, D], rv5: Gen[R, F], rv6: Gen[R, G])(test: (A, B, C, D, F, G) => TestResult)(implicit checkConstructor: CheckConstructor[R, In], trace: ZTraceElement): ZIO[OutEnvironment, OutError, TestResult]
A version of
checkthat accepts six random variables. - def check[R <: TestConfig, A, B, C, D, F, In](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C], rv4: Gen[R, D], rv5: Gen[R, F])(test: (A, B, C, D, F) => TestResult)(implicit checkConstructor: CheckConstructor[R, In], trace: ZTraceElement): ZIO[OutEnvironment, OutError, TestResult]
A version of
checkthat accepts five random variables. - def check[R <: TestConfig, A, B, C, D, In](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C], rv4: Gen[R, D])(test: (A, B, C, D) => In)(implicit checkConstructor: CheckConstructor[R, In], trace: ZTraceElement): ZIO[OutEnvironment, OutError, TestResult]
A version of
checkthat accepts four random variables. - def check[R <: TestConfig, A, B, C, In](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C])(test: (A, B, C) => In)(implicit checkConstructor: CheckConstructor[R, In], trace: ZTraceElement): ZIO[OutEnvironment, OutError, TestResult]
A version of
checkthat accepts three random variables. - def check[R <: TestConfig, A, B, In](rv1: Gen[R, A], rv2: Gen[R, B])(test: (A, B) => In)(implicit checkConstructor: CheckConstructor[R, In], trace: ZTraceElement): ZIO[OutEnvironment, OutError, TestResult]
A version of
checkthat accepts two random variables. - def check[R <: TestConfig, A, In](rv: Gen[R, A])(test: (A) => In)(implicit checkConstructor: CheckConstructor[R, In], trace: ZTraceElement): ZIO[OutEnvironment, OutError, TestResult]
Checks the test passes for "sufficient" numbers of samples from the given random variable.
- def checkAll[R <: TestConfig, A, B, C, D, F, G, In](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C], rv4: Gen[R, D], rv5: Gen[R, F], rv6: Gen[R, G])(test: (A, B, C, D, F, G) => In)(implicit checkConstructor: CheckConstructor[R, In], trace: ZTraceElement): ZIO[OutEnvironment, OutError, TestResult]
A version of
checkAllthat accepts six random variables. - def checkAll[R <: TestConfig, A, B, C, D, F, In](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C], rv4: Gen[R, D], rv5: Gen[R, F])(test: (A, B, C, D, F) => In)(implicit checkConstructor: CheckConstructor[R, In], trace: ZTraceElement): ZIO[OutEnvironment, OutError, TestResult]
A version of
checkAllthat accepts five random variables. - def checkAll[R <: TestConfig, A, B, C, D, In](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C], rv4: Gen[R, D])(test: (A, B, C, D) => In)(implicit checkConstructor: CheckConstructor[R, In], trace: ZTraceElement): ZIO[OutEnvironment, OutError, TestResult]
A version of
checkAllthat accepts four random variables. - def checkAll[R <: TestConfig, A, B, C, In](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C])(test: (A, B, C) => In)(implicit checkConstructor: CheckConstructor[R, In], trace: ZTraceElement): ZIO[OutEnvironment, OutError, TestResult]
A version of
checkAllthat accepts three random variables. - def checkAll[R <: TestConfig, A, B, In](rv1: Gen[R, A], rv2: Gen[R, B])(test: (A, B) => In)(implicit checkConstructor: CheckConstructor[R, In], trace: ZTraceElement): ZIO[OutEnvironment, OutError, TestResult]
A version of
checkAllthat accepts two random variables. - def checkAll[R <: TestConfig, A, In](rv: Gen[R, A])(test: (A) => In)(implicit checkConstructor: CheckConstructor[R, In], trace: ZTraceElement): ZIO[OutEnvironment, OutError, 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
Genthat comprehensively explore all possibilities in a given domain. - def checkAllPar[R <: TestConfig, R1 <: R, E, A, B, C, D, F, G, In](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C], rv4: Gen[R, D], rv5: Gen[R, F], rv6: Gen[R, G], parallelism: Int)(test: (A, B, C, D, F, G) => In)(implicit checkConstructor: CheckConstructor[R, In], trace: ZTraceElement): ZIO[OutEnvironment, OutError, TestResult]
A version of
checkAllMParthat accepts six random variables. - def checkAllPar[R <: TestConfig, R1 <: R, E, A, B, C, D, F, In](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C], rv4: Gen[R, D], rv5: Gen[R, F], parallelism: Int)(test: (A, B, C, D, F) => In)(implicit checkConstructor: CheckConstructor[R, In], trace: ZTraceElement): ZIO[OutEnvironment, OutError, TestResult]
A version of
checkAllMParthat accepts five random variables. - def checkAllPar[R <: TestConfig, R1 <: R, E, A, B, C, D, In](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C], rv4: Gen[R, D], parallelism: Int)(test: (A, B, C, D) => In)(implicit checkConstructor: CheckConstructor[R, In], trace: ZTraceElement): ZIO[OutEnvironment, OutError, TestResult]
A version of
checkAllMParthat accepts four random variables. - def checkAllPar[R <: TestConfig, R1 <: R, E, A, B, C, In](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C], parallelism: Int)(test: (A, B, C) => In)(implicit checkConstructor: CheckConstructor[R, In], trace: ZTraceElement): ZIO[OutEnvironment, OutError, TestResult]
A version of
checkAllMParthat accepts three random variables. - def checkAllPar[R <: TestConfig, R1 <: R, E, A, B, In](rv1: Gen[R, A], rv2: Gen[R, B], parallelism: Int)(test: (A, B) => In)(implicit checkConstructor: CheckConstructor[R, In], trace: ZTraceElement): ZIO[OutEnvironment, OutError, TestResult]
A version of
checkAllMParthat accepts two random variables. - def checkAllPar[R <: TestConfig, R1 <: R, E, A, In](rv: Gen[R, A], parallelism: Int)(test: (A) => In)(implicit checkConstructor: CheckConstructor[R, In], trace: ZTraceElement): ZIO[OutEnvironment, OutError, TestResult]
Checks in parallel the effectual test passes for all values from the given random variable.
Checks in parallel 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. - def checkN(n: Int): CheckN
Checks the test passes for the specified number of samples from the given random variable.
- val defaultTestRunner: TestRunner[TestEnvironment, Any]
A
Runnerthat provides a default testable environment. - def failed[E](cause: Cause[E])(implicit trace: ZTraceElement): ZIO[Any, TestFailure[E], Nothing]
Creates a failed test result with the specified runtime cause.
- val ignored: UIO[TestSuccess]
Creates an ignored test result.
- def live[E, A](zio: ZIO[ZEnv, E, A])(implicit trace: ZTraceElement): ZIO[Live, E, A]
Provides an effect with the "real" environment as opposed to the test environment.
Provides an effect with the "real" environment as opposed to the test environment. This is useful for performing effects such as timing out tests, accessing the real time, or printing to the real console.
- val liveEnvironment: Layer[Nothing, ZEnv]
- def platformSpecific[R, E, A](js: => A, jvm: => A)(f: (A) => ZTest[R, E]): ZTest[R, E]
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.
- def suite[In](label: String)(specs: In*)(implicit suiteConstructor: SuiteConstructor[In], trace: ZTraceElement): Spec[OutEnvironment, OutError, OutSuccess]
Builds a suite containing a number of other specs.
- def test[In](label: String)(assertion: => In)(implicit testConstructor: TestConstructor[Nothing, In], trace: ZTraceElement): Out
Builds a spec with a single test.
- val testEnvironment: Layer[Nothing, TestEnvironment]
- final macro def typeCheck(code: String): UIO[Either[String, Unit]]
Returns either
Rightif the specified string type checks as valid Scala code orLeftwith an error message otherwise.Returns either
Rightif the specified string type checks as valid Scala code orLeftwith an error message otherwise. Dies with a runtime exception if specified string cannot be parsed or is not a known value at compile time.- Definition Classes
- CompileVariants
- def versionSpecific[R, E, A](scala3: => A, scala2: => A)(f: (A) => ZTest[R, E]): ZTest[R, E]
Passes version specific information to the specified function, which will use that information to create a test.
Passes version specific information to the specified function, which will use that information to create a test. If the version is neither Scala 3 nor Scala 2, an ignored test result will be returned.
- def withLive[R, E, E1, A, B](zio: ZIO[R, E, A])(f: (IO[E, A]) => ZIO[ZEnv, E1, B])(implicit trace: ZTraceElement): ZIO[R with Live, E1, B]
Transforms this effect with the specified function.
Transforms this effect with the specified function. The test environment will be provided to this effect, but the live environment will be provided to the transformation function. This can be useful for applying transformations to an effect that require access to the "real" environment while ensuring that the effect itself uses the test environment.
withLive(test)(_.timeout(duration))
- object Annotations extends Serializable
- object Assert extends Serializable
- object Assertion extends AssertionVariants
- object AssertionData
- object AssertionM
- object AssertionMData
- object AssertionResult
- object AssertionValue
- object BoolAlgebra extends Serializable
- object BoolAlgebraM extends Serializable
- object CheckConstructor extends CheckConstructorLowPriority1
- object CheckVariants
- object CompileVariants
Proxy methods to call package private methods from the macro
- object CustomAssertion
- object DefaultTestReporter
- object Eql extends EqlLowPriority
- object ErrorMessage
- object ExecutedSpec extends Serializable
- object FailureCase extends Serializable
- object Gen extends GenZIO with FunctionVariants with TimeVariants with Serializable
- object GenFailureDetails
- object Live
- object Result
- object Sample extends Serializable
- object Sized extends Serializable
- object Spec extends Serializable
- object SuiteConstructor extends SuiteConstructorLowPriority1
- object SummaryBuilder
- object TestAnnotation extends Serializable
- object TestAnnotationMap
- object TestAnnotationRenderer
- object TestArgs extends Serializable
- object TestArrow
- object TestAspect extends TimeoutVariants
- object TestClock extends Serializable
- object TestConfig extends Serializable
- object TestConsole extends Serializable
- object TestConstructor extends TestConstructorLowPriority1
- object TestDuration
- object TestEnvironment
- object TestExecutor
- object TestFailure
- object TestLogger extends Serializable
- object TestPlatform
TestPlatformprovides information about the platform tests are being run on to enable platform specific test configuration. - object TestRandom extends Serializable
- object TestReporter
- object TestResult
- object TestSuccess
- object TestSystem extends Serializable
- object TestVersion
TestVersionprovides information about the Scala version tests are being run on to enable platform specific test configuration. - object Trace
- object ZTest
Deprecated Value Members
- def checkAllM[R <: TestConfig, R1 <: R, E, A, B, C, D, F, G](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C], rv4: Gen[R, D], rv5: Gen[R, F], rv6: Gen[R, G])(test: (A, B, C, D, F, G) => ZIO[R1, E, TestResult])(implicit trace: ZTraceElement): ZIO[R1, E, TestResult]
A version of
checkAllMthat accepts six random variables.A version of
checkAllMthat accepts six random variables.- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use checkAll
- def checkAllM[R <: TestConfig, R1 <: R, E, A, B, C, D, F](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C], rv4: Gen[R, D], rv5: Gen[R, F])(test: (A, B, C, D, F) => ZIO[R1, E, TestResult])(implicit trace: ZTraceElement): ZIO[R1, E, TestResult]
A version of
checkAllMthat accepts five random variables.A version of
checkAllMthat accepts five random variables.- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use checkAll
- def checkAllM[R <: TestConfig, R1 <: 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[R1, E, TestResult])(implicit trace: ZTraceElement): ZIO[R1, E, TestResult]
A version of
checkAllMthat accepts four random variables.A version of
checkAllMthat accepts four random variables.- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use checkAll
- def checkAllM[R <: TestConfig, R1 <: R, E, A, B, C](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C])(test: (A, B, C) => ZIO[R1, E, TestResult])(implicit trace: ZTraceElement): ZIO[R1, E, TestResult]
A version of
checkAllMthat accepts three random variables.A version of
checkAllMthat accepts three random variables.- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use checkAll
- def checkAllM[R <: TestConfig, R1 <: R, E, A, B](rv1: Gen[R, A], rv2: Gen[R, B])(test: (A, B) => ZIO[R1, E, TestResult])(implicit trace: ZTraceElement): ZIO[R1, E, TestResult]
A version of
checkAllMthat accepts two random variables.A version of
checkAllMthat accepts two random variables.- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use checkAll
- def checkAllM[R <: TestConfig, R1 <: R, E, A](rv: Gen[R, A])(test: (A) => ZIO[R1, E, TestResult])(implicit trace: ZTraceElement): ZIO[R1, 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
Genthat comprehensively explore all possibilities in a given domain.- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use checkAll
- def checkAllMPar[R <: TestConfig, R1 <: R, E, A, B, C, D, F, G](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C], rv4: Gen[R, D], rv5: Gen[R, F], rv6: Gen[R, G], parallelism: Int)(test: (A, B, C, D, F, G) => ZIO[R1, E, TestResult])(implicit trace: ZTraceElement): ZIO[R1, E, TestResult]
A version of
checkAllMParthat accepts six random variables.A version of
checkAllMParthat accepts six random variables.- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use checkPar
- def checkAllMPar[R <: TestConfig, R1 <: R, E, A, B, C, D, F](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C], rv4: Gen[R, D], rv5: Gen[R, F], parallelism: Int)(test: (A, B, C, D, F) => ZIO[R1, E, TestResult])(implicit trace: ZTraceElement): ZIO[R1, E, TestResult]
A version of
checkAllMParthat accepts five random variables.A version of
checkAllMParthat accepts five random variables.- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use checkPar
- def checkAllMPar[R <: TestConfig, R1 <: R, E, A, B, C, D](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C], rv4: Gen[R, D], parallelism: Int)(test: (A, B, C, D) => ZIO[R1, E, TestResult])(implicit trace: ZTraceElement): ZIO[R1, E, TestResult]
A version of
checkAllMParthat accepts four random variables.A version of
checkAllMParthat accepts four random variables.- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use checkPar
- def checkAllMPar[R <: TestConfig, R1 <: R, E, A, B, C](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C], parallelism: Int)(test: (A, B, C) => ZIO[R1, E, TestResult])(implicit trace: ZTraceElement): ZIO[R1, E, TestResult]
A version of
checkAllMParthat accepts three random variables.A version of
checkAllMParthat accepts three random variables.- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use checkPar
- def checkAllMPar[R <: TestConfig, R1 <: R, E, A, B](rv1: Gen[R, A], rv2: Gen[R, B], parallelism: Int)(test: (A, B) => ZIO[R1, E, TestResult])(implicit trace: ZTraceElement): ZIO[R1, E, TestResult]
A version of
checkAllMParthat accepts two random variables.A version of
checkAllMParthat accepts two random variables.- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use checkPar
- def checkAllMPar[R <: TestConfig, R1 <: R, E, A](rv: Gen[R, A], parallelism: Int)(test: (A) => ZIO[R1, E, TestResult])(implicit trace: ZTraceElement): ZIO[R1, E, TestResult]
Checks in parallel the effectual test passes for all values from the given random variable.
Checks in parallel 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.- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use checkPar
- def checkM[R <: TestConfig, R1 <: R, E, A, B, C, D, F, G](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C], rv4: Gen[R, D], rv5: Gen[R, F], rv6: Gen[R, G])(test: (A, B, C, D, F, G) => ZIO[R1, E, TestResult])(implicit trace: ZTraceElement): ZIO[R1, E, TestResult]
A version of
checkMthat accepts six random variables.A version of
checkMthat accepts six random variables.- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use check
- def checkM[R <: TestConfig, R1 <: R, E, A, B, C, D, F](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C], rv4: Gen[R, D], rv5: Gen[R, F])(test: (A, B, C, D, F) => ZIO[R1, E, TestResult])(implicit trace: ZTraceElement): ZIO[R1, E, TestResult]
A version of
checkMthat accepts five random variables.A version of
checkMthat accepts five random variables.- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use check
- def checkM[R <: TestConfig, R1 <: 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[R1, E, TestResult])(implicit trace: ZTraceElement): ZIO[R1, E, TestResult]
A version of
checkMthat accepts four random variables.A version of
checkMthat accepts four random variables.- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use check
- def checkM[R <: TestConfig, R1 <: R, E, A, B, C](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C])(test: (A, B, C) => ZIO[R1, E, TestResult])(implicit trace: ZTraceElement): ZIO[R1, E, TestResult]
A version of
checkMthat accepts three random variables.A version of
checkMthat accepts three random variables.- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use check
- def checkM[R <: TestConfig, R1 <: R, E, A, B](rv1: Gen[R, A], rv2: Gen[R, B])(test: (A, B) => ZIO[R1, E, TestResult])(implicit trace: ZTraceElement): ZIO[R1, E, TestResult]
A version of
checkMthat accepts two random variables.A version of
checkMthat accepts two random variables.- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use check
- def checkM[R <: TestConfig, R1 <: R, E, A](rv: Gen[R, A])(test: (A) => ZIO[R1, E, TestResult])(implicit trace: ZTraceElement): ZIO[R1, 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.
- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use check
- def checkNM(n: Int): CheckNM
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.
- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use checkN
- def suiteM[R, E, T](label: String)(specs: ZIO[R, E, Iterable[Spec[R, E, T]]])(implicit trace: ZTraceElement): Spec[R, E, T]
Builds an effectual suite containing a number of other specs.
Builds an effectual suite containing a number of other specs.
- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use suite
- def testM[R, E](label: String)(assertion: => ZIO[R, E, TestResult])(implicit trace: ZTraceElement): ZSpec[R, E]
Builds a spec with a single effectful test.
Builds a spec with a single effectful test.
- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use test