zio.test

package zio.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

 object MyTest extends ZIOSpecDefault {
   def spec = suite("clock")(
     test("time is non-zero") {
       for {
         time <- Live.live(nanoTime)
       } yield assertTrue(time >= 0L)
     }
   )
 }

Attributes

Members list

Packages

package zio.test.diff
package zio.test.laws

The laws package provides functionality for describing laws as values. The fundamental abstraction is a set of ZLaws[Caps, R]. These laws model the laws that instances having a capability of type Caps are expected to satisfy. A capability Caps[_] 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:

The laws package provides functionality for describing laws as values. The fundamental abstraction is a set of ZLaws[Caps, R]. These laws model the laws that instances having a capability of type Caps are expected to satisfy. A capability Caps[_] 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:

  1. Reflexivity - a1 === a1
  2. Symmetry - a1 === a2 ==> a2 === a1
  3. 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 ZLaws constructors. 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 run method that takes a generator of values of type A and checks that those values satisfy the laws. In addition, objects can extend ZLawful to 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.

Attributes

package zio.test.poly
package zio.test.render

Type members

Classlikes

trait Annotations extends Serializable

The Annotations trait 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 of Annotations as a more structured logging service or as a super polymorphic version of the writer monad effect.

The Annotations trait 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 of Annotations as a more structured logging service or as a super polymorphic version of the writer monad effect.

Attributes

Companion
object
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Known subtypes
class Test
object Annotations

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
final case class Assertion[-A](arrow: TestArrow[A, Boolean])

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Self type
object Assertion extends AssertionVariants

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Show all
Self type
Assertion.type

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Assertion.type
trait CheckConstructor[Environment, In]

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Show all
Self type

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object CheckConstructor.type

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object CheckVariants

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any

Proxy methods to call package private methods from the macro

Proxy methods to call package private methods from the macro

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
final class CustomAssertion[A, B]

CustomAssertion allows users to create their own custom assertions for use in assertTrue. They are constructed with CustomAssertion.make.

CustomAssertion allows users to create their own custom assertions for use in assertTrue. They are constructed with CustomAssertion.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)
 }
)

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
object ErrorMessage

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
sealed trait ErrorMessage

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
sealed trait ExecutionEvent

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class RuntimeFailure[E]
class SectionEnd
class SectionStart
class Test[E]
class TestStarted
Show all

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
case class FailureCase(errorMessage: Message, codeString: String, location: String, path: Chunk[(String, String)], span: Span, nestedFailures: Chunk[FailureCase], result: Any, customLabel: Option[String])

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object FailureCase

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object GenF2.type
object Gen.type
final case class Gen[-R, +A](sample: ZStream[R, Nothing, Sample[R, A]])

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

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

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Self type
Gen[R, A]

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
trait TimeVariants
trait GenZIO
class Object
trait Matchable
class Any
Show all
Self type
Gen.type
sealed abstract class GenFailureDetails

GenFailureDetails keeps track of relevant information related to a failure in a generative test.

GenFailureDetails keeps track of relevant information related to a failure in a generative test.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
trait GenZIO

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Gen.type
trait Live

The Live trait provides access to the "live" default ZIO services from within ZIO Test for workflows such as printing test results to the console or timing out tests where it is necessary to access the real implementations of these services.

The Live trait provides access to the "live" default ZIO services from within ZIO Test for workflows such as printing test results to the console or timing out tests where it is necessary to access the real implementations of these services.

The easiest way to access the "live" services is to use the live method with a workflow that would otherwise use the test version of the default ZIO services.

import zio.Clock
import zio.test._

val realTime = live(Clock.nanoTime)

The withLive method can be used to apply a transformation to a workflow with the live services while ensuring that the workflow itself still runs with the test services, for example to time out a test. Both of these methods are re-exported in the ZIO Test package object for easy availability.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Test
object Live

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Live.type
object Macros

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Macros.type

Attributes

Supertypes
class Object
trait Matchable
class Any
final class ProvideSomePartiallyApplied[R0, -R, +E](val self: Spec[R, E]) extends AnyVal

Attributes

Supertypes
class AnyVal
trait Matchable
class Any
final class ProvideSomeSharedPartiallyApplied[R0, -R, +E](val self: Spec[R, E]) extends AnyVal

Attributes

Supertypes
class AnyVal
trait Matchable
class Any

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
trait Restorable extends Serializable

Attributes

Supertypes
trait Serializable
class Object
trait Matchable
class Any
Known subtypes
trait TestClock
class Test
trait TestConsole
class Test
trait TestRandom
class Test
trait TestSystem
class Test
Show all
sealed trait Result[+A]

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Die
object Fail.type
class Succeed[A]
Self type
Result[A]
object Result

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Result.type
final case class Sample[-R, +A](value: A, shrink: ZStream[R, Nothing, Sample[R, A]])

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

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

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Self type
Sample[R, A]
object Sample

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Sample.type
trait Sized extends Serializable

Attributes

Companion
object
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Known subtypes
class Test
object Sized

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Sized.type

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
final implicit class SmartAssertionOps[A](self: A) extends AnyVal

Attributes

Supertypes
class AnyVal
trait Matchable
class Any
final case class Spec[-R, +E](caseValue: SpecCase[R, E, Spec[R, E]]) extends SpecVersionSpecific[R, E]

A Spec[R, E] is the backbone of ZIO Test. Every spec is either a suite, which contains other specs, or a test. All specs require an environment of type R and may potentially fail with an error of type E.

A Spec[R, E] is the backbone of ZIO Test. Every spec is either a suite, which contains other specs, or a test. All specs require an environment of type R and may potentially fail with an error of type E.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait SpecVersionSpecific[R, E]
class Object
trait Matchable
class Any
Show all
Self type
Spec[R, E]
object Spec

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Spec.type

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
trait SpecVersionSpecific[-R, +E]

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Spec[R, E]
Self type
Spec[R, E]
trait SuiteConstructor[In]

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
trait
Supertypes
Self type

Attributes

Supertypes
class Object
trait Matchable
class Any
Show all
Known subtypes
object SuiteConstructor.type

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
case class SuiteId(id: Int)

Value parameters

id

Level of the spec nesting that you are at. Suites get new values, test cases inherit their suite's

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object SuiteId

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
SuiteId.type
sealed case class Summary(success: Int, fail: Int, ignore: Int, failureDetails: String, duration: Duration)

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Self type
object Summary

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Summary.type

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
final class TestAnnotation[V] extends Serializable

A type of annotation.

A type of annotation.

Attributes

Companion
object
Supertypes
trait Serializable
class Object
trait Matchable
class Any

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
final class TestAnnotationMap

An annotation map keeps track of annotations of different types.

An annotation map keeps track of annotations of different types.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
sealed abstract class TestAnnotationRenderer

A TestAnnotationRenderer knows how to render test annotations.

A TestAnnotationRenderer knows how to render test annotations.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
Self type

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
object TestArgs

Attributes

Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
TestArgs.type
sealed trait TestArrow[-A, +B]

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class And[A]
class AndThen[A, B, C]
class Meta[A, B]
class Not[A]
class Or[A]
class Suspend[A, B]
class TestArrowF[A, B]
Show all
Self type
TestArrow[A, B]
object TestArrow

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
TestArrow.type
abstract class TestAspect[+LowerR, -UpperR, +LowerE, -UpperE]

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

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

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class PerTest[LowerR, UpperR, LowerE, UpperE]
Self type
TestAspect[LowerR, UpperR, LowerE, UpperE]
object TestAspect extends TimeoutVariants

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
TestAspect.type
trait TestClock extends Clock, Restorable

TestClock makes it easy to deterministically and efficiently test effects involving the passage of time.

TestClock makes it easy to deterministically and efficiently test effects involving the passage of time.

Instead of waiting for actual time to pass, sleep and methods implemented in terms of it schedule effects to take place at a given clock time. Users can adjust the clock time using the adjust and setTime methods, 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#timeout using TestClock:

 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 sleep was invoked on. Calls to sleep and 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 using TestClock is 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.

Attributes

Companion
object
Supertypes
trait Restorable
trait Clock
trait Serializable
class Object
trait Matchable
class Any
Show all
Known subtypes
class Test
object TestClock extends Serializable

Attributes

Companion
trait
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Self type
TestClock.type

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Test
Self type
trait TestConfig extends Serializable

The TestConfig service 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.

The TestConfig service 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.

Attributes

Companion
object
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Known subtypes
class Test
object TestConfig

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
TestConfig.type
trait TestConsole extends Console, Restorable

TestConsole provides 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 by TestConsole and backed by a Ref.

TestConsole provides 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 by TestConsole and backed by a Ref.

All calls to print and printLine using the TestConsole will write the string to the output buffer and all calls to readLine will 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 using debug, silent, or the corresponding test aspects.

TestConsole has several methods to access and manipulate the content of these buffers including feedLines to feed strings to the input buffer that will then be returned by calls to readLine, output to get the content of the output buffer from calls to print and printLine, and clearInput and clearOutput to 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")

Attributes

Companion
object
Supertypes
trait Restorable
trait Console
trait Serializable
class Object
trait Matchable
class Any
Show all
Known subtypes
class Test
object TestConsole extends Serializable

Attributes

Companion
trait
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Self type
trait TestConstructor[-Environment, In]

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Show all
Self type

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object TestConstructor.type

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
sealed trait TestDuration

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Self type
object TestDuration

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
abstract class TestExecutor[+R, E]

A TestExecutor[R, E] is capable of executing specs that require an environment R and may fail with an E.

A TestExecutor[R, E] is capable of executing specs that require an environment R and may fail with an E.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object TestExecutor

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
sealed abstract class TestFailure[+E]

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Assertion
class Runtime[E]
Self type
object TestFailure

Attributes

Companion
class
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
final case class TestLens[+A]()

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final implicit class TestLensAnyOps[A](self: TestLens[A]) extends AnyVal

Attributes

Supertypes
class AnyVal
trait Matchable
class Any
final implicit class TestLensCauseOps[E](self: TestLens[Cause[E]]) extends AnyVal

Attributes

Supertypes
class AnyVal
trait Matchable
class Any
final implicit class TestLensEitherOps[E, A](self: TestLens[Either[E, A]]) extends AnyVal

Attributes

Supertypes
class AnyVal
trait Matchable
class Any
final implicit class TestLensExitOps[E, A](self: TestLens[Exit[E, A]]) extends AnyVal

Attributes

Supertypes
class AnyVal
trait Matchable
class Any
final implicit class TestLensOptionOps[A](self: TestLens[Option[A]]) extends AnyVal

Attributes

Supertypes
class AnyVal
trait Matchable
class Any
trait TestLogger extends Serializable

Attributes

Companion
object
Supertypes
trait Serializable
class Object
trait Matchable
class Any
object TestLogger

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
TestLogger.type
object TestPlatform

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

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

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
trait TestRandom extends Random, Restorable

TestRandom allows for deterministically testing effects involving randomness.

TestRandom allows for deterministically testing effects involving randomness.

TestRandom operates in two modes. In the first mode, TestRandom is a purely functional pseudo-random number generator. It will generate pseudo-random values just like scala.util.Random except that no internal state is mutated. Instead, methods like nextInt describe state transitions from one random state to another that are automatically composed together through methods like flatMap. The random seed can be set using setSeed and TestRandom is 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, TestRandom maintains an internal buffer of values that can be "fed" with methods such as feedInts and 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

TestRandom will 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 like clearInts to 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.

Attributes

Companion
object
Supertypes
trait Restorable
trait Random
trait Serializable
class Object
trait Matchable
class Any
Show all
Known subtypes
class Test
object TestRandom extends Serializable

Attributes

Companion
trait
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Self type
TestRandom.type
object TestReporters

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
case class TestReporters(reportersStack: Ref[List[SuiteId]])

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class TestResult(arrow: TestArrow[Any, Boolean])

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Self type
object TestResult

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
TestResult.type
final implicit class TestResultZIOOps[R, E](self: ZIO[R, E, TestResult]) extends AnyVal

Attributes

Supertypes
class AnyVal
trait Matchable
class Any
final case class TestRunner[R, E](executor: TestExecutor[R, E])

A TestRunner[R, E] encapsulates all the logic necessary to run specs that require an environment R and may fail with an error E. Test runners require a test executor, a runtime configuration, and a reporter.

A TestRunner[R, E] encapsulates all the logic necessary to run specs that require an environment R and may fail with an error E. Test runners require a test executor, a runtime configuration, and a reporter.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Self type
TestRunner[R, E]
object TestServices

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
sealed abstract class TestSuccess

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Ignored
class Succeeded
Self type
object TestSuccess

Attributes

Companion
class
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
trait TestSystem extends System, Restorable

TestSystem supports deterministic testing of effects involving system properties. Internally, TestSystem maintains 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.

TestSystem supports deterministic testing of effects involving system properties. Internally, TestSystem maintains 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")

Attributes

Companion
object
Supertypes
trait Restorable
trait System
trait Serializable
class Object
trait Matchable
class Any
Show all
Known subtypes
class Test
object TestSystem extends Serializable

Attributes

Companion
trait
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Self type
TestSystem.type
final case class TestTimeoutException(message: String) extends Throwable

Attributes

Supertypes
trait Product
trait Equals
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
sealed trait TestTrace[+A]

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Self type
object TestTrace

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
TestTrace.type
object TestVersion

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

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

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
trait TimeVariants

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Gen.type

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object TestAspect.type
abstract class ZIOSpec[R] extends ZIOSpecAbstract, ZIOSpecVersionSpecific[R]

Attributes

Supertypes
trait ZIOApp
class Object
trait Matchable
class Any
Show all
Known subtypes
Self type
ZIOSpec[R]

Attributes

Supertypes
trait ZIOApp
class Object
trait Matchable
class Any
Show all
Known subtypes
class ZIOSpec[R]
Self type

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
class ZIOSpecAbstractSpecificMacros(val ctx: Quotes)

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class ZIOSpec[R]
abstract class ZIOSpecDefault extends ZIOSpec[TestEnvironment]

Attributes

Supertypes

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class ZIOSpec[R]
Self type
ZIOSpec[R]

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object ZTest

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
ZTest.type

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
sealed trait ZTestLogger[-Message, +Output] extends ZLogger[Message, Output]

A ZTestLogger is an implementation of a ZLogger that writes all log messages to an internal data structure. The contents of this data structure can be accessed using the logOutput operator. This makes it easy to write tests to verify that expected messages are being logged.

A ZTestLogger is an implementation of a ZLogger that writes all log messages to an internal data structure. The contents of this data structure can be accessed using the logOutput operator. This makes it easy to write tests to verify that expected messages are being logged.

test("logging works") {
 for {
   _      <- ZIO.logDebug("It's alive!")
   output <- ZTestLogger.logOutput
 } yield assertTrue(output.length == 1) &&
   assertTrue(output(0).message() == "It's alive!") &&
   assertTrue(output(0).logLevel == LogLevel.Debug)
}

Attributes

Companion
object
Supertypes
trait ZLogger[Message, Output]
class Object
trait Matchable
class Any
object ZTestLogger

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type

Types

type TestAspectAtLeastR[-R] = TestAspect[Nothing, R, Nothing, Any]

A TestAspectAtLeast[R] is a TestAspect that requires at least an R in its environment.

A TestAspectAtLeast[R] is a TestAspect that requires at least an R in its environment.

Attributes

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

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

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

Attributes

type ZTest[-R, +E] = ZIO[R, TestFailure[E], TestSuccess]

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

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

Attributes

Value members

Concrete methods

def annotations(implicit trace: Trace): UIO[Annotations]

Retrieves the Annotations service for this test.

Retrieves the Annotations service for this test.

Attributes

def annotationsWith[R, E, A](f: Annotations => ZIO[R, E, A])(implicit trace: Trace): ZIO[R, E, A]

Retrieves the Annotations service for this test and uses it to run the specified workflow.

Retrieves the Annotations service for this test and uses it to run the specified workflow.

Attributes

def assertCompletes(implicit trace: Trace, sourceLocation: SourceLocation): TestResult

Asserts that the given test was completed.

Asserts that the given test was completed.

Attributes

def assertCompletesZIO(implicit trace: Trace, sourceLocation: SourceLocation): UIO[TestResult]

Asserts that the given test was completed.

Asserts that the given test was completed.

Attributes

def assertNever(message: String)(implicit trace: Trace, sourceLocation: SourceLocation): TestResult

Asserts that the given test was never completed.

Asserts that the given test was never completed.

Attributes

def check[R <: ZAny, A, In](rv: Gen[R, A])(test: A => In)(implicit checkConstructor: CheckConstructor[R, In], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, 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.

Attributes

def check[R <: ZAny, A, B, In](rv1: Gen[R, A], rv2: Gen[R, B])(test: (A, B) => In)(implicit checkConstructor: CheckConstructor[R, In], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

A version of check that accepts two random variables.

A version of check that accepts two random variables.

Attributes

def check[R <: ZAny, 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], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

A version of check that accepts three random variables.

A version of check that accepts three random variables.

Attributes

def check[R <: ZAny, 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], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

A version of check that accepts four random variables.

A version of check that accepts four random variables.

Attributes

def check[R <: ZAny, 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], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

A version of check that accepts five random variables.

A version of check that accepts five random variables.

Attributes

def check[R <: ZAny, 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], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

A version of check that accepts six random variables.

A version of check that accepts six random variables.

Attributes

def check[R <: ZAny, A, B, C, D, F, G, H, 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], rv7: Gen[R, H])(test: (A, B, C, D, F, G, H) => In)(implicit checkConstructor: CheckConstructor[R, In], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

A version of check that accepts seven random variables.

A version of check that accepts seven random variables.

Attributes

def check[R <: ZAny, A, B, C, D, F, G, H, I, 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], rv7: Gen[R, H], rv8: Gen[R, I])(test: (A, B, C, D, F, G, H, I) => In)(implicit checkConstructor: CheckConstructor[R, In], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

A version of check that accepts eight random variables.

A version of check that accepts eight random variables.

Attributes

def checkAll[R <: ZAny, A, In](rv: Gen[R, A])(test: A => In)(implicit checkConstructor: CheckConstructor[R, In], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

Checks the test passes for all values from the given finite, deterministic generator. For non-deterministic or infinite generators use check or checkN.

Checks the test passes for all values from the given finite, deterministic generator. For non-deterministic or infinite generators use check or checkN.

Attributes

def checkAll[R <: ZAny, A, B, In](rv1: Gen[R, A], rv2: Gen[R, B])(test: (A, B) => In)(implicit checkConstructor: CheckConstructor[R, In], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

A version of checkAll that accepts two random variables.

A version of checkAll that accepts two random variables.

Attributes

def checkAll[R <: ZAny, 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], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

A version of checkAll that accepts three random variables.

A version of checkAll that accepts three random variables.

Attributes

def checkAll[R <: ZAny, 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], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

A version of checkAll that accepts four random variables.

A version of checkAll that accepts four random variables.

Attributes

def checkAll[R <: ZAny, 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], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

A version of checkAll that accepts five random variables.

A version of checkAll that accepts five random variables.

Attributes

def checkAll[R <: ZAny, 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], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

A version of checkAll that accepts six random variables.

A version of checkAll that accepts six random variables.

Attributes

def checkAll[R <: ZAny, A, B, C, D, F, G, H, 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], rv7: Gen[R, H])(test: (A, B, C, D, F, G, H) => In)(implicit checkConstructor: CheckConstructor[R, In], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

A version of checkAll that accepts seven random variables.

A version of checkAll that accepts seven random variables.

Attributes

def checkAll[R <: ZAny, E, A, B, C, D, F, G, H, I, 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], rv7: Gen[R, H], rv8: Gen[R, I])(test: (A, B, C, D, F, G, H, I) => In)(implicit checkConstructor: CheckConstructor[R, In], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

A version of checkAll that accepts eight random variables.

A version of checkAll that accepts eight random variables.

Attributes

def checkAllPar[R <: ZAny, E, A, In](rv: Gen[R, A], parallelism: Int)(test: A => In)(implicit checkConstructor: CheckConstructor[R, In], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

Checks in parallel 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.

Checks in parallel 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.

Attributes

def checkAllPar[R <: ZAny, E, A, B, In](rv1: Gen[R, A], rv2: Gen[R, B], parallelism: Int)(test: (A, B) => In)(implicit checkConstructor: CheckConstructor[R, In], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

A version of checkAllPar that accepts two random variables.

A version of checkAllPar that accepts two random variables.

Attributes

def checkAllPar[R <: ZAny, 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], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

A version of checkAllPar that accepts three random variables.

A version of checkAllPar that accepts three random variables.

Attributes

def checkAllPar[R <: ZAny, 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], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

A version of checkAllPar that accepts four random variables.

A version of checkAllPar that accepts four random variables.

Attributes

def checkAllPar[R <: ZAny, 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], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

A version of checkAllPar that accepts five random variables.

A version of checkAllPar that accepts five random variables.

Attributes

def checkAllPar[R <: ZAny, 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], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

A version of checkAllPar that accepts six random variables.

A version of checkAllPar that accepts six random variables.

Attributes

def checkAllPar[R <: ZAny, E, A, B, C, D, F, G, H, 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], rv7: Gen[R, H], parallelism: Int)(test: (A, B, C, D, F, G, H) => In)(implicit checkConstructor: CheckConstructor[R, In], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

A version of checkAllPar that accepts six random variables.

A version of checkAllPar that accepts six random variables.

Attributes

def checkAllPar[R <: ZAny, E, A, B, C, D, F, G, H, I, 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], rv7: Gen[R, H], rv8: Gen[R, I], parallelism: Int)(test: (A, B, C, D, F, G, H, I) => In)(implicit checkConstructor: CheckConstructor[R, In], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

A version of checkAllPar that accepts six random variables.

A version of checkAllPar that accepts six random variables.

Attributes

def checkN(n: Int): CheckN

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.

Attributes

def checkPar[R <: ZAny, A, In](rv: Gen[R, A], parallelism: Int)(test: A => In)(implicit checkConstructor: CheckConstructor[R, In], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

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

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

Attributes

def checkPar[R <: ZAny, A, B, In](rv1: Gen[R, A], rv2: Gen[R, B], parallelism: Int)(test: (A, B) => In)(implicit checkConstructor: CheckConstructor[R, In], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

A version of checkPar that accepts two random variables.

A version of checkPar that accepts two random variables.

Attributes

def checkPar[R <: ZAny, 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], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

A version of checkPar that accepts three random variables.

A version of checkPar that accepts three random variables.

Attributes

def checkPar[R <: ZAny, 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], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

A version of checkPar that accepts four random variables.

A version of checkPar that accepts four random variables.

Attributes

def checkPar[R <: ZAny, 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], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

A version of checkPar that accepts five random variables.

A version of checkPar that accepts five random variables.

Attributes

def checkPar[R <: ZAny, 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], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

A version of checkPar that accepts six random variables.

A version of checkPar that accepts six random variables.

Attributes

def checkPar[R <: ZAny, A, B, C, D, F, G, H, 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], rv7: Gen[R, H], parallelism: Int)(test: (A, B, C, D, F, G, H) => In)(implicit checkConstructor: CheckConstructor[R, In], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

A version of checkPar that accepts seven random variables.

A version of checkPar that accepts seven random variables.

Attributes

def checkPar[R <: ZAny, A, B, C, D, F, G, H, I, 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], rv7: Gen[R, H], rv8: Gen[R, I], parallelism: Int)(test: (A, B, C, D, F, G, H, I) => In)(implicit checkConstructor: CheckConstructor[R, In], sourceLocation: SourceLocation, trace: Trace): ZIO[OutEnvironment, OutError, TestResult]

A version of checkPar that accepts eight random variables.

A version of checkPar that accepts eight random variables.

Attributes

def failed[E](cause: Cause[E])(implicit trace: Trace): ZIO[Any, TestFailure[E], Nothing]

Creates a failed test result with the specified runtime cause.

Creates a failed test result with the specified runtime cause.

Attributes

def live[R, E, A](zio: ZIO[R, E, A])(implicit trace: Trace): ZIO[R, E, A]

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.

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.

Attributes

def live(implicit trace: Trace): UIO[Live]

Retrieves the Live service for this test.

Retrieves the Live service for this test.

Attributes

def liveWith[R, E, A](f: Live => ZIO[R, E, A])(implicit trace: Trace): ZIO[R, E, A]

Retrieves the Live service for this test and uses it to run the specified workflow.

Retrieves the Live service for this test and uses it to run the specified workflow.

Attributes

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. If the platform is neither ScalaJS nor the JVM, an ignored test result will be returned.

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.

Attributes

def sized(implicit trace: Trace): UIO[Sized]

Retrieves the Sized service for this test.

Retrieves the Sized service for this test.

Attributes

def sizedWith[R, E, A](f: Sized => ZIO[R, E, A])(implicit trace: Trace): ZIO[R, E, A]

Retrieves the Sized service for this test and uses it to run the specified workflow.

Retrieves the Sized service for this test and uses it to run the specified workflow.

Attributes

def suite[In](label: String)(specs: In*)(implicit suiteConstructor: SuiteConstructor[In], sourceLocation: SourceLocation, trace: Trace): Spec[OutEnvironment, OutError]

Builds a suite containing a number of other specs.

Builds a suite containing a number of other specs.

Attributes

def test[In](label: String)(assertion: => In)(implicit testConstructor: TestConstructor[Nothing, In], sourceLocation: SourceLocation, trace: Trace): Out

Builds a spec with a single test.

Builds a spec with a single test.

Attributes

def testClock(implicit trace: Trace): UIO[TestClock]

Retrieves the TestClock service for this test.

Retrieves the TestClock service for this test.

Attributes

def testClockWith[R, E, A](f: TestClock => ZIO[R, E, A])(implicit trace: Trace): ZIO[R, E, A]

Retrieves the TestClock service for this test and uses it to run the specified workflow.

Retrieves the TestClock service for this test and uses it to run the specified workflow.

Attributes

def testConfig(implicit trace: Trace): UIO[TestConfig]

Retrieves the TestConfig service for this test.

Retrieves the TestConfig service for this test.

Attributes

def testConfigWith[R, E, A](f: TestConfig => ZIO[R, E, A])(implicit trace: Trace): ZIO[R, E, A]

Retrieves the TestConfig service for this test and uses it to run the specified workflow.

Retrieves the TestConfig service for this test and uses it to run the specified workflow.

Attributes

def testConsole(implicit trace: Trace): UIO[TestConsole]

Retrieves the TestConsole service for this test.

Retrieves the TestConsole service for this test.

Attributes

def testConsoleWith[R, E, A](f: TestConsole => ZIO[R, E, A])(implicit trace: Trace): ZIO[R, E, A]

Retrieves the TestConsole service for this test and uses it to run the specified workflow.

Retrieves the TestConsole service for this test and uses it to run the specified workflow.

Attributes

def testRandom(implicit trace: Trace): UIO[TestRandom]

Retrieves the TestRandom service for this test.

Retrieves the TestRandom service for this test.

Attributes

def testRandomWith[R, E, A](f: TestRandom => ZIO[R, E, A])(implicit trace: Trace): ZIO[R, E, A]

Retrieves the TestRandom service for this test and uses it to run the specified workflow.

Retrieves the TestRandom service for this test and uses it to run the specified workflow.

Attributes

def testSystem(implicit trace: Trace): UIO[TestSystem]

Retrieves the TestSystem service for this test.

Retrieves the TestSystem service for this test.

Attributes

def testSystemWith[R, E, A](f: TestSystem => ZIO[R, E, A])(implicit trace: Trace): ZIO[R, E, A]

Retrieves the TestSystem service for this test and uses it to run the specified workflow.

Retrieves the TestSystem service for this test and uses it to run the specified workflow.

Attributes

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. If the version is neither Scala 3 nor Scala 2, an ignored test result will be returned.

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.

Attributes

def withAnnotations[R, E, A <: Annotations, B](annotations: => A)(zio: => ZIO[R, E, B])(implicit tag: Tag[A], trace: Trace): ZIO[R, E, B]

Executes the specified workflow with the specified implementation of the annotations service.

Executes the specified workflow with the specified implementation of the annotations service.

Attributes

def withAnnotationsScoped[A <: Annotations](annotations: => A)(implicit tag: Tag[A], trace: Trace): ZIO[Scope, Nothing, Unit]

Sets the implementation of the annotations service to the specified value and restores it to its original value when the scope is closed.

Sets the implementation of the annotations service to the specified value and restores it to its original value when the scope is closed.

Attributes

def withLive[R, E, A <: Live, B](live: => A)(zio: => ZIO[R, E, B])(implicit tag: Tag[A], trace: Trace): ZIO[R, E, B]

Executes the specified workflow with the specified implementation of the live service.

Executes the specified workflow with the specified implementation of the live service.

Attributes

def withLive[R, E, E1, A, B](zio: ZIO[R, E, A])(f: ZIO[R, E, A] => ZIO[R, E1, B])(implicit trace: Trace): ZIO[R, E1, B]

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.

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))

Attributes

def withLiveScoped[A <: Live](live: => A)(implicit tag: Tag[A], trace: Trace): ZIO[Scope, Nothing, Unit]

Sets the implementation of the live service to the specified value and restores it to its original value when the scope is closed.

Sets the implementation of the live service to the specified value and restores it to its original value when the scope is closed.

Attributes

def withSized[R, E, A <: Sized, B](sized: => A)(zio: => ZIO[R, E, B])(implicit tag: Tag[A], trace: Trace): ZIO[R, E, B]

Executes the specified workflow with the specified implementation of the sized service.

Executes the specified workflow with the specified implementation of the sized service.

Attributes

def withSizedScoped[A <: Sized](sized: => A)(implicit tag: Tag[A], trace: Trace): ZIO[Scope, Nothing, Unit]

Sets the implementation of the sized service to the specified value and restores it to its original value when the scope is closed.

Sets the implementation of the sized service to the specified value and restores it to its original value when the scope is closed.

Attributes

def withTestConfig[R, E, A <: TestConfig, B](testConfig: => A)(zio: => ZIO[R, E, B])(implicit tag: Tag[A], trace: Trace): ZIO[R, E, B]

Executes the specified workflow with the specified implementation of the config service.

Executes the specified workflow with the specified implementation of the config service.

Attributes

def withTestConfigScoped[A <: TestConfig](testConfig: => A)(implicit tag: Tag[A], trace: Trace): ZIO[Scope, Nothing, Unit]

Sets the implementation of the config service to the specified value and restores it to its original value when the scope is closed.

Sets the implementation of the config service to the specified value and restores it to its original value when the scope is closed.

Attributes

Inherited methods

inline def assert[A](inline value: => A)(inline assertion: Assertion[A])(implicit trace: Trace, sourceLocation: SourceLocation): TestResult

Attributes

Inherited from:
CompileVariants
inline def assertTrue(inline exprs: => Boolean*)(implicit sourceLocation: SourceLocation): TestResult

Attributes

Inherited from:
CompileVariants
inline def assertZIO[R, E, A](effect: ZIO[R, E, A])(assertion: Assertion[A]): ZIO[R, E, TestResult]

Attributes

Inherited from:
CompileVariants
inline def typeCheck(inline code: String): UIO[Either[String, Unit]]

Returns either Right if the specified string type checks as valid Scala code or Left with an error message otherwise. Dies with a runtime exception if specified string cannot be parsed or is not a known value at compile time.

Returns either Right if the specified string type checks as valid Scala code or Left with an error message otherwise. Dies with a runtime exception if specified string cannot be parsed or is not a known value at compile time.

Attributes

Inherited from:
CompileVariants

Concrete fields

A Runner that provides a default testable environment.

A Runner that provides a default testable environment.

Attributes

Creates an ignored test result.

Creates an ignored test result.

Attributes

val testEnvironment: ZLayer[Any, Nothing, TestEnvironment]

Implicits

Implicits

final implicit def SmartAssertionOps[A](self: A): SmartAssertionOps[A]
final implicit def TestLensAnyOps[A](self: TestLens[A]): TestLensAnyOps[A]
final implicit def TestLensCauseOps[E](self: TestLens[Cause[E]]): TestLensCauseOps[E]
final implicit def TestLensEitherOps[E, A](self: TestLens[Either[E, A]]): TestLensEitherOps[E, A]
final implicit def TestLensExitOps[E, A](self: TestLens[Exit[E, A]]): TestLensExitOps[E, A]
final implicit def TestLensOptionOps[A](self: TestLens[Option[A]]): TestLensOptionOps[A]
final implicit def TestResultZIOOps[R, E](self: ZIO[R, E, TestResult]): TestResultZIOOps[R, E]