ZSuite

munit.ZSuite
abstract class ZSuite extends FunSuite, ZAssertions, ZFixtures, ZFixtureSyntax, ZRuntime

Attributes

Graph
Supertypes
trait ZRuntime
trait ZFixtures
trait ZAssertions
class FunSuite
trait ValueTransforms
trait SuiteTransforms
trait TestTransforms
trait TestOptionsConversions
trait FunFixtures
trait Assertions
trait CompileErrorMacro
class Suite
trait PlatformSuite
class Object
trait Matchable
class Any
Show all

Members list

Type members

Classlikes

class WrongTestMethodError extends Exception

Attributes

Supertypes
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all

Inherited classlikes

abstract class Fixture[T](val fixtureName: String)

Value parameters

name

The name of this fixture, used for displaying an error message if beforeAll() or afterAll() fail.

Attributes

Inherited from:
Suite
Supertypes
class Object
trait Matchable
class Any
implicit class FixtureSyntax[T](fixture: FunFixture[T])

Attributes

Inherited from:
ZFixtureSyntax
Supertypes
class Object
trait Matchable
class Any
class FunFixture[T]

Attributes

Inherited from:
FunFixtures
Supertypes
class Object
trait Matchable
class Any
object FunFixture

Attributes

Inherited from:
FunFixtures
Supertypes
class Object
trait Matchable
class Any
implicit class InterceptSyntax[R, E <: Throwable](body: ZIO[R, E, Any])

Attributes

Inherited from:
ZAssertions
Supertypes
class Object
trait Matchable
class Any
implicit class LayerFixtureSyntax[R](fixture: FunFixture[ULayer[R]])

Attributes

Inherited from:
ZFixtureSyntax
Supertypes
class Object
trait Matchable
class Any
final class SuiteTransform(val name: String, fn: List[Test] => List[Test]) extends List[Test] => List[Test]

Attributes

Inherited from:
SuiteTransforms
Supertypes
trait List[Test] => List[Test]
class Object
trait Matchable
class Any
final class TestTransform(val name: String, fn: Test => Test) extends Test => Test

Attributes

Inherited from:
TestTransforms
Supertypes
trait Test => Test
class Object
trait Matchable
class Any
final class ValueTransform(val name: String, fn: PartialFunction[Any, Future[Any]]) extends Any => Option[Future[Any]]

Attributes

Inherited from:
ValueTransforms
Supertypes
trait Any => Option[Future[Any]]
class Object
trait Matchable
class Any

Suite local fixture from Scoped effect.

Suite local fixture from Scoped effect.


var state   = 0
val fixture = ZSuiteLocalFixture(
 "sample",
 ZIO.acquireRelease(ZIO.attempt { state += 1; state })(_ => ZIO.attempt { state -= 1 }.orDie)
)

override val munitFixtures = Seq(fixture)

test("suite local fixture works") {
 assertEquals(fixture(), 1)
}

Attributes

Inherited from:
ZFixtures
Supertypes
class Object
trait Matchable
class Any

Test-local fixture.

Test-local fixture.

Can be created from raw setup/teardown effects or from Scoped effect.

val rawZIOFunFixture = ZTestLocalFixture(options => ZIO.succeed(s"acquired ${options.name}")) { str =>
 putStrLn(s"cleanup [$str]").provideLayer(Console.live)
}

val scopedFunFixture = ZTestLocalFixture { options =>
 ZIO.acquireRelease(ZIO.succeed(s"acquired ${options.name} with Scoped")) { str =>
   printLine(s"cleanup [$str] with Scoped").orDie
 }
}

rawZIOFunFixture.test("allocate resource with ZIO FunFixture") { str =>
 assertNoDiff(str, "acquired allocate resource with ZIO FunFixture")
}

scopedFunFixture.test("allocate resource with Scoped FunFixture") { str =>
 assertNoDiff(str, "acquired allocate resource with Scoped FunFixture with Scoped")
}

Attributes

Inherited from:
ZFixtures
Supertypes
class Object
trait Matchable
class Any

Inherited types

final type AfterEach = GenericAfterEach[TestValue]

Attributes

Inherited from:
Suite
final type BeforeEach = GenericBeforeEach[TestValue]

Attributes

Inherited from:
Suite
final type Test = GenericTest[TestValue]

Attributes

Inherited from:
Suite
final type TestValue = Future[Any]

The value produced by test bodies.

The value produced by test bodies.

Attributes

Inherited from:
FunSuite

Value members

Concrete methods

override def munitValueTransforms: List[ValueTransform]

Attributes

Definition Classes
ValueTransforms
def testZ[E](name: String)(body: IO[E, Any])(implicit loc: Location): Unit

Runs test returning ZIO[Any, E, Any]

Runs test returning ZIO[Any, E, Any]

testZ("simple effect test") {
 val effect = for
   a <- ZIO(1)
   b <- ZIO(2)
 yield a + b

 assertEqualsZ(effect, 3)
}

Value parameters

body

test body

name

test name

Attributes

def testZ[E](options: TestOptions)(body: IO[E, Any])(implicit loc: Location): Unit

Inherited methods

def afterAll(): Unit

Runs once after all test cases and after all suite-local fixtures have been tear down.

Runs once after all test cases and after all suite-local fixtures have been tear down.

Attributes

Inherited from:
Suite
def afterEach(context: AfterEach): Unit

Runs after each individual test case.

Runs after each individual test case.

Attributes

Inherited from:
Suite
def assert(cond: => Boolean, clue: => Any)(implicit loc: Location): Unit

Attributes

Inherited from:
Assertions
def assertEquals[A, B](obtained: A, expected: B, clue: => Any)(implicit loc: Location, ev: B <:< A): Unit

Asserts that two elements are equal using == equality.

Asserts that two elements are equal using == equality.

The "expected" value (second argument) must have the same type or be a subtype of the "obtained" value (first argument). For example:

 assertEquals(Option(1), Some(1)) // OK
 assertEquals(Some(1), Option(1)) // Error: Option[Int] is not a subtype of Some[Int]

Use assertEquals[Any, Any](a, b) as an escape hatch to compare two values of different types. For example:

 val a: Either[List[String], Int] = Right(42)
 val b: Either[String, Int]       = Right(42)
 assertEquals[Any, Any](a, b) // OK
 assertEquals(a, b) // Error: Either[String, Int] is not a subtype of Either[List[String], Int]

Attributes

Inherited from:
Assertions
def assertEqualsDouble(obtained: Double, expected: Double, delta: Double, clue: => Any)(implicit loc: Location): Unit

Asserts that two doubles are equal to within a positive delta. If the expected value is infinity then the delta value is ignored. NaNs are considered equal: assertEquals(Double.NaN, Double.NaN, *) passes.

Asserts that two doubles are equal to within a positive delta. If the expected value is infinity then the delta value is ignored. NaNs are considered equal: assertEquals(Double.NaN, Double.NaN, *) passes.

Attributes

Inherited from:
Assertions
def assertEqualsFloat(obtained: Float, expected: Float, delta: Float, clue: => Any)(implicit loc: Location): Unit

Asserts that two floats are equal to within a positive delta. If the expected value is infinity then the delta value is ignored. NaNs are considered equal: assertEquals(Float.NaN, Float.NaN, *) passes.

Asserts that two floats are equal to within a positive delta. If the expected value is infinity then the delta value is ignored. NaNs are considered equal: assertEquals(Float.NaN, Float.NaN, *) passes.

Attributes

Inherited from:
Assertions
final def assertEqualsZ[R, E, A, B](obtained: ZIO[R, E, A], expected: B, clue: => Any)(implicit loc: Location, ev: B <:< A): ZIO[R, E, Unit]

Asserts that ZIO[R, E, A] returns the same result as expected

Asserts that ZIO[R, E, A] returns the same result as expected

 testZ("strings are the same") {
   val effect = ZIO.succeed("string")
   assertEqualsZ(effect, "string", "different strings")
 }

Value parameters

clue

a value that will be printed in case the assertions fail

expected

expected result

obtained

the effect to be tested

Attributes

Inherited from:
ZAssertions
def assertNoDiff(obtained: String, expected: String, clue: => Any)(implicit loc: Location): Unit

Attributes

Inherited from:
Assertions
final def assertNoDiffZ[R, E](obtained: ZIO[R, E, String], expected: String, clue: => Any)(implicit loc: Location): ZIO[R, E, Unit]

Asserts that ZIO[R, E, String] has no difference with expected string. Pretty prints diff unlike just assertEqualsZ.

Asserts that ZIO[R, E, String] has no difference with expected string. Pretty prints diff unlike just assertEqualsZ.

 testZ("strings are the same") {
   val effect = ZIO.succeed("string")
   assertNoDiffZ(effect, "string", "different strings")
 }

Value parameters

clue

a value that will be printed in case the assertions fail

expected

expected string

obtained

the string effect to be tested

Attributes

Inherited from:
ZAssertions
def assertNotEquals[A, B](obtained: A, expected: B, clue: => Any)(implicit loc: Location, ev: A =:= B): Unit

Attributes

Inherited from:
Assertions
final def assertNotEqualsZ[R, E, A, B](obtained: ZIO[R, E, A], expected: B, clue: => Any)(implicit loc: Location, ev: A =:= B): ZIO[R, E, Unit]

Asserts that ZIO[R, E, A] returns NOT the same result as expected

Asserts that ZIO[R, E, A] returns NOT the same result as expected

 testZ("strings are the same") {
   val effect = ZIO.succeed("string")
   assertNotEqualsZ(effect, "another string", "same strings")
 }

Value parameters

clue

a value that will be printed in case the assertions fail

expected

expected result

obtained

the effect to be tested

Attributes

Inherited from:
ZAssertions
final def assertZ[R, E](cond: ZIO[R, E, Boolean], clue: => Any)(implicit loc: Location): ZIO[R, E, Unit]

Asserts that ZIO[R, E, Boolean] returns true.

Asserts that ZIO[R, E, Boolean] returns true.

 testZ("false OR true should be true") {
   val effect = ZIO.succeed(false || true)
   assertZ(effect, "boolean algebra check failed")
 }

Value parameters

clue

a value that will be printed in case the assertions fail

cond

the boolean effect to be tested

Attributes

Inherited from:
ZAssertions
def assume(cond: Boolean, clue: => Any)(implicit loc: Location): Unit

Attributes

Inherited from:
Assertions
def beforeAll(): Unit

Runs once before all test cases and before all suite-local fixtures are setup. An error in this method aborts the test suite.

Runs once before all test cases and before all suite-local fixtures are setup. An error in this method aborts the test suite.

Attributes

Inherited from:
Suite
def beforeEach(context: BeforeEach): Unit

Runs before each individual test case. An error in this method aborts the test case.

Runs before each individual test case. An error in this method aborts the test case.

Attributes

Inherited from:
Suite
def clue[T](c: Clue[T]): T

Attributes

Inherited from:
Assertions
def clues(clue: Clue[_]*): Clues

Attributes

Inherited from:
Assertions
inline def compileErrors(inline code: String): String

Attributes

Inherited from:
CompileErrorMacro
def fail(message: String, clues: Clues)(implicit loc: Location): Nothing

Attributes

Inherited from:
Assertions
def fail(message: String, cause: Throwable)(implicit loc: Location): Nothing

Attributes

Inherited from:
Assertions
def failComparison(message: String, obtained: Any, expected: Any, clues: Clues)(implicit loc: Location): Nothing

Attributes

Inherited from:
Assertions
def failSuite(message: String, clues: Clues)(implicit loc: Location): Nothing

Attributes

Inherited from:
Assertions
def intercept[T <: Throwable](body: => Any)(implicit T: ClassTag[T], loc: Location): T

Attributes

Inherited from:
Assertions
def interceptMessage[T <: Throwable](expectedExceptionMessage: String)(body: => Any)(implicit T: ClassTag[T], loc: Location): T

Attributes

Inherited from:
Assertions
def isCI: Boolean

Attributes

Inherited from:
SuiteTransforms
def munitAnsiColors: Boolean

Attributes

Inherited from:
Assertions
def munitCaptureClues[T](thunk: => T): (T, Clues)

Attributes

Inherited from:
Assertions
def munitExecutionContext: ExecutionContext

Attributes

Inherited from:
Suite

Attributes

Inherited from:
TestTransforms
def munitFixtures: Seq[Fixture[_]]

Functinonal fixtures that can be reused for individual test cases or entire suites.

Functinonal fixtures that can be reused for individual test cases or entire suites.

Attributes

Inherited from:
Suite
def munitFlakyOK: Boolean

Attributes

Inherited from:
TestTransforms

Attributes

Inherited from:
TestTransforms

Attributes

Inherited from:
ValueTransforms
def munitIgnore: Boolean

Attributes

Inherited from:
SuiteTransforms

Attributes

Inherited from:
SuiteTransforms

Attributes

Inherited from:
SuiteTransforms
def munitPrint(clue: => Any): String

Attributes

Inherited from:
Assertions
final def munitSuiteTransform(tests: List[Test]): List[Test]

Attributes

Inherited from:
SuiteTransforms

Attributes

Inherited from:
SuiteTransforms
final def munitTestTransform(test: Test): Test

Attributes

Inherited from:
TestTransforms

Attributes

Inherited from:
TestTransforms
def munitTests(): Seq[Test]

The base class for all test suites

The base class for all test suites

Attributes

Inherited from:
FunSuite
def munitTimeout: Duration

Attributes

Inherited from:
FunSuite
final def munitValueTransform(testValue: => Any): Future[Any]

Attributes

Inherited from:
ValueTransforms
def test(options: TestOptions)(body: => Any)(implicit loc: Location): Unit

Attributes

Inherited from:
FunSuite
def test(name: String)(body: => Any)(implicit loc: Location): Unit

Attributes

Inherited from:
FunSuite

Inherited fields

val munitLines: Lines

Attributes

Inherited from:
Assertions
final val munitTestsBuffer: ListBuffer[Test]

Attributes

Inherited from:
FunSuite
protected val runtime: Runtime[Any]

Attributes

Inherited from:
ZRuntime

Implicits

Inherited implicits

final implicit def FixtureSyntax[T](fixture: FunFixture[T]): FixtureSyntax[T]

Attributes

Inherited from:
ZFixtureSyntax
final implicit def InterceptSyntax[R, E <: Throwable](body: ZIO[R, E, Any]): InterceptSyntax[R, E]

Attributes

Inherited from:
ZAssertions
final implicit def LayerFixtureSyntax[R](fixture: FunFixture[ULayer[R]]): LayerFixtureSyntax[R]

Attributes

Inherited from:
ZFixtureSyntax
implicit def testOptionsFromString(name: String)(implicit loc: Location): TestOptions

Implicitly create a TestOptions given a test name. This allows writing test("name") { ... } even if test accepts a TestOptions

Implicitly create a TestOptions given a test name. This allows writing test("name") { ... } even if test accepts a TestOptions

Attributes

Inherited from:
TestOptionsConversions