Packages

  • package root
    Definition Classes
    root
  • package zio
    Definition Classes
    root
  • package test

    _ZIO Test_ is a featherweight testing library for effectful programs.

    _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")(
        testM("time is non-zero") {
          assertM(nanoTime)(isGreaterThan(0))
        }
      )
    }
    Definition Classes
    zio
  • package environment

    The environment package contains testable versions of all the standard ZIO environment types through the TestClock, TestConsole, TestSystem, and TestRandom modules.

    The environment package contains testable versions of all the standard ZIO environment types through the TestClock, TestConsole, TestSystem, and TestRandom modules. See the documentation on the individual modules for more detail about using each of them.

    If you are using ZIO Test and extending RunnableSpec a TestEnvironment containing all of them will be automatically provided to each of your tests. Otherwise, the easiest way to use the test implementations in ZIO Test is by providing the TestEnvironment to your program.

    import zio.test.environment._
    
    myProgram.provideLayer(testEnvironment)

    Then all environmental effects, such as printing to the console or generating random numbers, will be implemented by the TestEnvironment and will be fully testable. When you do need to access the "live" environment, for example to print debugging information to the console, just use the live combinator along with the effect as your normally would.

    If you are only interested in one of the test implementations for your application, you can also access them a la carte through the make method on each module. Each test module requires some data on initialization. Default data is included for each as DefaultData.

    import zio.test.environment._
    
    myProgram.provideM(TestConsole.make(TestConsole.DefaultData))

    Finally, you can create a Test object that implements the test interface directly using the makeTest method. This can be useful when you want to access some testing functionality without using the environment type.

    import zio.test.environment._
    
    for {
      testRandom <- TestRandom.makeTest(TestRandom.DefaultData)
      n          <- testRandom.nextInt
    } yield n

    This can also be useful when you are creating a more complex environment to provide the implementation for test services that you mix in.

    Definition Classes
    test
  • package laws

    The laws package provides functionality for describing laws as values.

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

    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.

    Definition Classes
    test
  • package mock
    Definition Classes
    test
  • package poly
    Definition Classes
    test
  • package reflect
    Definition Classes
    test
  • AbstractRunnableSpec
  • Annotations
  • Assertion
  • AssertionData
  • AssertionM
  • AssertionMData
  • AssertionValue
  • AssertionVariants
  • BoolAlgebra
  • BoolAlgebraM
  • CheckVariants
  • CompileVariants
  • DefaultRunnableSpec
  • DefaultTestReporter
  • Eql
  • FailureDetails
  • FailureRenderer
  • FunctionVariants
  • Gen
  • GenFailureDetails
  • GenZIO
  • RenderedResult
  • RunnableSpec
  • Sample
  • Sized
  • Spec
  • Summary
  • SummaryBuilder
  • TestAnnotation
  • TestAnnotationMap
  • TestAnnotationRenderer
  • TestArgs
  • TestAspect
  • TestExecutor
  • TestFailure
  • TestLogger
  • TestPlatform
  • TestReporter
  • TestRunner
  • TestSuccess
  • TestTimeoutException
  • TestVersion
  • TimeVariants
  • TimeoutVariants
  • ZTest

object TestAspect extends TimeoutVariants

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. TestAspect
  2. TimeoutVariants
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. trait PerTest[+LowerR, -UpperR, +LowerE, -UpperE] extends TestAspect[LowerR, UpperR, LowerE, UpperE]

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def after[R0, E0](effect: ZIO[R0, E0, Any]): TestAspect[Nothing, R0, E0, Any]

    Constructs an aspect that runs the specified effect after every test.

  5. def annotate[V](key: TestAnnotation[V], value: V): TestAspectPoly

    Annotates tests with the specified test annotation.

  6. def around[R0, E0, A0](before: ZIO[R0, E0, A0])(after: (A0) ⇒ ZIO[R0, Nothing, Any]): TestAspect[Nothing, R0, E0, Any]

    Constructs an aspect that evaluates every test between two effects, before and after, where the result of before can be used in after.

  7. def aroundTest[R0, E0](managed: ZManaged[R0, TestFailure[E0], (TestSuccess) ⇒ ZIO[R0, TestFailure[E0], TestSuccess]]): TestAspect[Nothing, R0, E0, Any]

    Constructs an aspect that evaluates every test inside the context of the managed function.

  8. def around_[R0, E0](before: ZIO[R0, E0, Any], after: ZIO[R0, Nothing, Any]): TestAspect[Nothing, R0, E0, Any]

    A less powerful variant of around where the result of before is not required by after.

  9. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  10. def aspect[R0, E0](f: (ZIO[R0, TestFailure[E0], TestSuccess]) ⇒ ZIO[R0, TestFailure[E0], TestSuccess]): TestAspect[R0, R0, E0, E0]

    Constructs a simple monomorphic aspect that only works with the specified environment and error type.

  11. def before[R0, E0](effect: ZIO[R0, Nothing, Any]): TestAspect[Nothing, R0, E0, Any]

    Constructs an aspect that runs the specified effect before every test.

  12. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  13. val debug: TestAspectAtLeastR[TestConsole]

    An aspect that runs each test with the TestConsole instance in the environment set to debug mode so that console output is rendered to standard output in addition to being written to the output buffer.

  14. def diagnose(duration: Duration): TestAspectAtLeastR[Live]

    An aspect that runs each test on a separate fiber and prints a fiber dump if the test fails or has not terminated within the specified duration.

  15. def dotty[LowerR, UpperR, LowerE, UpperE](that: TestAspect[LowerR, UpperR, LowerE, UpperE]): TestAspect[LowerR, UpperR, LowerE, UpperE]

    An aspect that applies the specified aspect on Dotty.

  16. val dottyOnly: TestAspectAtLeastR[Annotations]

    An aspect that only runs tests on Dotty.

  17. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  18. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  19. val eventually: TestAspectAtLeastR[ZTestEnv]

    An aspect that retries a test until success, without limit.

  20. val exceptDotty: TestAspectAtLeastR[Annotations]

    An aspect that runs tests on all versions except Dotty.

  21. val exceptJS: TestAspectAtLeastR[Annotations]

    An aspect that runs tests on all platforms except ScalaJS.

  22. val exceptJVM: TestAspectAtLeastR[Annotations]

    An aspect that runs tests on all platforms except the JVM.

  23. val exceptNative: TestAspectAtLeastR[Annotations]

    An aspect that runs tests on all platforms except ScalaNative.

  24. val exceptScala2: TestAspectAtLeastR[Annotations]

    An aspect that runs tests on all versions except Scala 2.

  25. val exceptScala211: TestAspectAtLeastR[Annotations]

    An aspect that runs tests on all versions except Scala 2.11.

  26. val exceptScala212: TestAspectAtLeastR[Annotations]

    An aspect that runs tests on all versions except Scala 2.12.

  27. val exceptScala213: TestAspectAtLeastR[Annotations]

    An aspect that runs tests on all versions except Scala 2.13.

  28. def executionStrategy(exec: ExecutionStrategy): TestAspectPoly

    An aspect that sets suites to the specified execution strategy, but only if their current strategy is inherited (undefined).

  29. def failing[E0](assertion: Assertion[TestFailure[E0]]): TestAspect[Nothing, Any, Nothing, E0]

    An aspect that makes a test that failed for the specified failure pass.

    An aspect that makes a test that failed for the specified failure pass. Note that the test will fail for other failures and also if it passes correctly.

  30. val failing: TestAspectPoly

    An aspect that makes a test that failed for any reason pass.

    An aspect that makes a test that failed for any reason pass. Note that if the test passes this aspect will make it fail.

  31. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  32. def flaky(n: Int): TestAspectAtLeastR[ZTestEnv with Annotations]

    An aspect that retries a test until success, with the specified limit, for use with flaky tests.

  33. val flaky: TestAspectAtLeastR[ZTestEnv with Annotations]

    An aspect that retries a test until success, with a default limit, for use with flaky tests.

  34. val forked: TestAspectPoly

    An aspect that runs each test on its own separate fiber.

  35. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  36. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  37. val identity: TestAspectPoly

    An aspect that returns the tests unchanged

  38. def ifEnv(env: String, assertion: Assertion[String]): TestAspectAtLeastR[Live with Annotations]

    An aspect that only runs a test if the specified environment variable satisfies the specified assertion.

  39. def ifEnvSet(env: String): TestAspectAtLeastR[Live with Annotations]

    As aspect that only runs a test if the specified environment variable is set.

  40. def ifProp(prop: String, assertion: Assertion[String]): TestAspectAtLeastR[Live with Annotations]

    An aspect that only runs a test if the specified Java property satisfies the specified assertion.

  41. def ifPropSet(prop: String): TestAspectAtLeastR[Live with Annotations]

    As aspect that only runs a test if the specified Java property is set.

  42. val ignore: TestAspectAtLeastR[Annotations]

    An aspect that marks tests as ignored.

  43. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  44. def js[LowerR, UpperR, LowerE, UpperE](that: TestAspect[LowerR, UpperR, LowerE, UpperE]): TestAspect[LowerR, UpperR, LowerE, UpperE]

    An aspect that applies the specified aspect on ScalaJS.

  45. val jsOnly: TestAspectAtLeastR[Annotations]

    An aspect that only runs tests on ScalaJS.

  46. def jvm[LowerR, UpperR, LowerE, UpperE](that: TestAspect[LowerR, UpperR, LowerE, UpperE]): TestAspect[LowerR, UpperR, LowerE, UpperE]

    An aspect that applies the specified aspect on the JVM.

  47. val jvmOnly: TestAspectAtLeastR[Annotations]

    An aspect that only runs tests on the JVM.

  48. def native[LowerR, UpperR, LowerE, UpperE](that: TestAspect[LowerR, UpperR, LowerE, UpperE]): TestAspect[LowerR, UpperR, LowerE, UpperE]

    An aspect that applies the specified aspect on ScalaNative.

  49. val nativeOnly: TestAspectAtLeastR[Annotations]

    An aspect that only runs tests on ScalaNative.

  50. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  51. def nonFlaky(n: Int): TestAspectAtLeastR[ZTestEnv with Annotations]

    An aspect that repeats the test a specified number of times, ensuring it is stable ("non-flaky").

    An aspect that repeats the test a specified number of times, ensuring it is stable ("non-flaky"). Stops at the first failure.

  52. val nonFlaky: TestAspectAtLeastR[ZTestEnv with Annotations]

    An aspect that repeats the test a default number of times, ensuring it is stable ("non-flaky").

    An aspect that repeats the test a default number of times, ensuring it is stable ("non-flaky"). Stops at the first failure.

  53. def nonTermination(duration: Duration): TestAspectAtLeastR[Live]

    Constructs an aspect that requires a test to not terminate within the specified time.

  54. val nondeterministic: TestAspectAtLeastR[Live with TestRandom]

    Sets the seed of the TestRandom instance in the environment to a random value before each test.

  55. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  56. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  57. val parallel: TestAspectPoly

    An aspect that executes the members of a suite in parallel.

  58. def parallelN(n: Int): TestAspectPoly

    An aspect that executes the members of a suite in parallel, up to the specified number of concurrent fibers.

  59. def repeat[R0 <: ZTestEnv with Annotations](schedule: Schedule[R0, TestSuccess, Any]): TestAspectAtLeastR[R0]

    An aspect that repeats successful tests according to a schedule.

  60. def restore[R0](service: (R0) ⇒ Restorable): TestAspectAtLeastR[R0]

    An aspect that restores a given Restorable's state to its starting state after the test is run.

    An aspect that restores a given Restorable's state to its starting state after the test is run. Note that this is only useful when repeating tests.

  61. def restoreTestClock: TestAspectAtLeastR[TestClock]

    An aspect that restores the TestClock's state to its starting state after the test is run.

    An aspect that restores the TestClock's state to its starting state after the test is run. Note that this is only useful when repeating tests.

  62. def restoreTestConsole: TestAspectAtLeastR[TestConsole]

    An aspect that restores the TestConsole's state to its starting state after the test is run.

    An aspect that restores the TestConsole's state to its starting state after the test is run. Note that this is only useful when repeating tests.

  63. def restoreTestEnvironment: TestAspectAtLeastR[ZTestEnv]

    An aspect that restores all state in the standard provided test environments (TestClock, TestConsole, TestRandom and TestSystem) to their starting state after the test is run.

    An aspect that restores all state in the standard provided test environments (TestClock, TestConsole, TestRandom and TestSystem) to their starting state after the test is run. Note that this is only useful when repeating tests.

  64. def restoreTestRandom: TestAspectAtLeastR[TestRandom]

    An aspect that restores the TestRandom's state to its starting state after the test is run.

    An aspect that restores the TestRandom's state to its starting state after the test is run. Note that this is only useful when repeating tests.

  65. def restoreTestSystem: TestAspectAtLeastR[ZTestEnv]

    An aspect that restores the TestSystem's state to its starting state after the test is run.

    An aspect that restores the TestSystem's state to its starting state after the test is run. Note that this is only useful when repeating tests.

  66. def retry[R0 <: ZTestEnv with Annotations, E0](schedule: Schedule[R0, TestFailure[E0], Any]): TestAspect[Nothing, R0, Nothing, E0]

    An aspect that retries failed tests according to a schedule.

  67. def scala2[LowerR, UpperR, LowerE, UpperE](that: TestAspect[LowerR, UpperR, LowerE, UpperE]): TestAspect[LowerR, UpperR, LowerE, UpperE]

    An aspect that applies the specified aspect on Scala 2.

  68. def scala211[LowerR, UpperR, LowerE, UpperE](that: TestAspect[LowerR, UpperR, LowerE, UpperE]): TestAspect[LowerR, UpperR, LowerE, UpperE]

    An aspect that applies the specified aspect on Scala 2.11.

  69. val scala211Only: TestAspectAtLeastR[Annotations]

    An aspect that only runs tests on Scala 2.11.

  70. def scala212[LowerR, UpperR, LowerE, UpperE](that: TestAspect[LowerR, UpperR, LowerE, UpperE]): TestAspect[LowerR, UpperR, LowerE, UpperE]

    An aspect that applies the specified aspect on Scala 2.12.

  71. val scala212Only: TestAspectAtLeastR[Annotations]

    An aspect that only runs tests on Scala 2.12.

  72. def scala213[LowerR, UpperR, LowerE, UpperE](that: TestAspect[LowerR, UpperR, LowerE, UpperE]): TestAspect[LowerR, UpperR, LowerE, UpperE]

    An aspect that applies the specified aspect on Scala 2.13.

  73. val scala213Only: TestAspectAtLeastR[Annotations]

    An aspect that only runs tests on Scala 2.13.

  74. val scala2Only: TestAspectAtLeastR[Annotations]

    An aspect that only runs tests on Scala 2.

  75. val sequential: TestAspectPoly

    An aspect that executes the members of a suite sequentially.

  76. def setSeed(seed: ⇒ Long): TestAspectAtLeastR[TestRandom]

    Sets the seed of the TestRandom instance in the environment to the specified value before each test.

  77. val silent: TestAspectAtLeastR[TestConsole]

    An aspect that runs each test with the TestConsole instance in the environment set to silent mode so that console output is only written to the output buffer and not rendered to standard output.

  78. val success: TestAspectPoly

    An aspect that converts ignored tests into test failures.

  79. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  80. def tag(tag: String, tags: String*): TestAspectPoly

    Annotates tests with string tags.

  81. val timed: TestAspectAtLeastR[Live with Annotations]

    Annotates tests with their execution times.

  82. def timeout(duration: Duration): TestAspectAtLeastR[Live]

    An aspect that times out tests using the specified duration.

    An aspect that times out tests using the specified duration.

    duration

    maximum test duration

  83. def timeoutWarning(duration: Duration): TestAspect[Nothing, Live, Nothing, Any]

    A test aspect that prints a warning to the console when a test takes longer than the specified duration.

    A test aspect that prints a warning to the console when a test takes longer than the specified duration.

    Definition Classes
    TimeoutVariants
  84. def toString(): String
    Definition Classes
    AnyRef → Any
  85. def verify[R0, E0](condition: ⇒ ZIO[R0, E0, TestResult]): TestAspect[Nothing, R0, E0, Any]

    Verifies the specified post-condition after each test is run.

  86. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  87. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  88. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  89. object PerTest

Inherited from TimeoutVariants

Inherited from AnyRef

Inherited from Any

Ungrouped