github zio/zio v1.0.0-RC11

latest releases: v2.1.0-RC5, v2.1.0-RC4, v2.1.0-RC3...
4 years ago

ZIO Test

Early beta version of dependency-free test library for (pure FP) effectful programs. Critical constructs include:

  • Spec - A value-level representation for a specification
  • ZSpec - An alias for a Spec whose tests are ZIO effects
  • Predicate - Composable predicates with detailed error messages
  • zio.test.{ assert, assertM, check, checkAll, checkSome, suite, test, testM } - The building blocks for constructing specs
  • RunnableSpec - Specs will extend this (or DefaultRunnableSpec)
  • TestRunner - Every runnable spec points to a spec runner
  • TestAspect - Features that can be added to specs, such as timeouts, retries, etc.
  • Gen - Generators for property-testing based on ZIO Stream

ZIO Test has excellent support for environmental effects; specs that use the ZIO environmental effects (Console, Clock, etc.) will automatically (in DefaultRunnableSpec) be provided with a newly-created mock environment, meaning they will execute fast and deterministically. Users can supply their own mock environments when extending RunnableSpec.

ZIO Test Example:

class MySpec extends DefaultRunnableSpec {
  import Predicate._
  import zio.random._
  import zio.test.TestAspect.{ flaky, timeout }

  suite("An example suite") {
    test("addition") {
      assert(2 + 2, equals(4))
    },
    testM("random.nextDouble") { 
      assertM(nextDouble, isGreaterThanEqual(0.0) && isLessThanEqual(1.0)) 
    },
    (flaky >>> timeout(10.seconds)) {
      testM("flaky random.nextDouble") {
        assertM(nextDouble, isGreaterThan(0.5))
      }
    }
  }
}

Other notable changes

ZIO

ZManaged

ZSchedule

ZStream and ZSink

Promise

Semaphore

Don't miss a new zio release

NewReleases is sending notifications on new releases.