CatsEffectAssertions
- Companion
- class
trait CatsEffectAssertions
trait Assertions
trait CompileErrorMacro
class Object
trait Matchable
class Any
Type members
Inherited classlikes
Value members
Inherited methods
def assertEqualsDouble(obtained: Double, expected: Double, delta: Double, clue: => Any)(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.
If the expected value is infinity then the delta value is ignored.
NaNs are considered equal: assertEquals(Double.NaN, Double.NaN, *) passes.
- Inhertied from
- Assertions
Intercepts a
Throwable
being thrown inside the provided IO
.- Example
- {{{
val io = IO.raiseErrorUnit
interceptIOMyException
}}}
or
{{{
interceptIO[MyException] {
IO.raiseErrorUnit
}
}}} - Inhertied from
- CatsEffectAssertions
def interceptMessageIO[T <: Throwable](expectedExceptionMessage: String)(io: IO[Any])(T: ClassTag[T], loc: Location): IO[T]
Intercepts a
Throwable
with a certain message being thrown inside the provided IO
.- Example
- {{{
val io = IO.raiseErrorUnit
interceptIOMyException(io)
}}}
or
{{{
interceptIO[MyException] {
IO.raiseErrorUnit
}
}}} - Inhertied from
- CatsEffectAssertions
Intercepts a
Throwable
being thrown inside the provided SyncIO
.- Example
- {{{
val io = SyncIO.raiseErrorUnit
interceptSyncIOMyException
}}}
or
{{{
interceptSyncIO[MyException] {
SyncIO.raiseErrorUnit
}
}}} - Inhertied from
- CatsEffectAssertions
def intercept[T <: Throwable](body: => Any)(T: ClassTag[T], loc: Location): T
- Inhertied from
- Assertions
def interceptMessageSyncIO[T <: Throwable](expectedExceptionMessage: String)(io: SyncIO[Any])(T: ClassTag[T], loc: Location): SyncIO[T]
Intercepts a
Throwable
with a certain message being thrown inside the provided SyncIO
.- Example
- {{{
val io = SyncIO.raiseErrorUnit
interceptSyncIOMyException(io)
}}}
or
{{{
interceptSyncIO[MyException] {
SyncIO.raiseErrorUnit
}
}}} - Inhertied from
- CatsEffectAssertions
def interceptMessage[T <: Throwable](expectedExceptionMessage: String)(body: => Any)(T: ClassTag[T], loc: Location): T
- Inhertied from
- Assertions
def failComparison(message: String, obtained: Any, expected: Any, clues: Clues)(loc: Location): Nothing
- Inhertied from
- Assertions
def assertEqualsFloat(obtained: Float, expected: Float, delta: Float, clue: => Any)(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.
If the expected value is infinity then the delta value is ignored.
NaNs are considered equal: assertEquals(Float.NaN, Float.NaN, *) passes.
- Inhertied from
- Assertions
Asserts that an
IO
returns an expected value.The "returns" value (second argument) must have the same type or be a
subtype of the one "contained" inside the
{{{
assertIO(IO(Option(1)), returns = Some(1)) // OK
assertIO(IO(Some(1)), returns = Option(1)) // Error: Option[Int] is not a subtype of Some[Int]
}}}
subtype of the one "contained" inside the
IO
(first argument). For example:{{{
assertIO(IO(Option(1)), returns = Some(1)) // OK
assertIO(IO(Some(1)), returns = Option(1)) // Error: Option[Int] is not a subtype of Some[Int]
}}}
The "clue" value can be used to give extra information about the failure in case the
assertion fails.
assertion fails.
- Value Params
- clue
-
a value that will be printed in case the assertions fails
- obtained
-
the IO under testing
- returns
-
the expected value
- Inhertied from
- CatsEffectAssertions
def assertNotEquals[A, B](obtained: A, expected: B, clue: => Any)(loc: Location, ev: A =:= B): Unit
- Inhertied from
- Assertions
def assertSyncIO[A, B](obtained: SyncIO[A], returns: B, clue: => Any)(loc: Location, ev: B <:< A): SyncIO[Unit]
Asserts that a
SyncIO
returns an expected value.The "returns" value (second argument) must have the same type or be a
subtype of the one "contained" inside the
{{{
assertSyncIO(SyncIO(Option(1)), returns = Some(1)) // OK
assertSyncIO(SyncIO(Some(1)), returns = Option(1)) // Error: Option[Int] is not a subtype of Some[Int]
}}}
subtype of the one "contained" inside the
SyncIO
(first argument). For example:{{{
assertSyncIO(SyncIO(Option(1)), returns = Some(1)) // OK
assertSyncIO(SyncIO(Some(1)), returns = Option(1)) // Error: Option[Int] is not a subtype of Some[Int]
}}}
The "clue" value can be used to give extra information about the failure in case the
assertion fails.
assertion fails.
- Value Params
- clue
-
a value that will be printed in case the assertions fails
- obtained
-
the SyncIO under testing
- returns
-
the expected value
- Inhertied from
- CatsEffectAssertions
def assertNoDiff(obtained: String, expected: String, clue: => Any)(loc: Location): Unit
- Inhertied from
- Assertions
def assertEquals[A, B](obtained: A, expected: B, clue: => Any)(loc: Location, ev: B <:< A): Unit
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]
}}}
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
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]
}}}
assertEquals[Any, Any](a, b)
as an escape hatch to compare twovalues 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]
}}}
- Inhertied from
- Assertions