RunTimedMatchers

trait RunTimedMatchers[F[_]]

This trait provides matchers for IO-like datatypes which can be executed given an execution environment.

This trait provides matchers for IO-like datatypes which can be executed given an execution environment.

For example you can write with cats.effect

"adding 1 + 1" ! IO(add(1, 1)) must returnValue(2)

However this example will be executed synchronously so those matchers are better used with test libraries which don't support asynchronous execution (like JUnit).

A better approach is to provide an implicit, like the one provided in specs2-cats to convert an IO value into a specs2 Execution. Then you can directly write:

"adding 1 + 1" ! IO(add(1, 1) === 2)

class Object
trait Matchable
class Any

Type members

Classlikes

open class TimedMatcher[T](check: ValueCheck[T], duration: Option[FiniteDuration]) extends Matcher[F[T]]

This Matchers supports combinations of value + duration checks

This Matchers supports combinations of value + duration checks

Value members

Abstract methods

protected def runAwait[A](fa: F[A]): A
protected def runWithTimeout[A](fa: F[A], timeout: FiniteDuration): A

Concrete methods

def returnBefore[T](duration: FiniteDuration): TimedMatcher[T]

succeed if a value is returned before a given time

succeed if a value is returned before a given time

succeed if a value is returned

succeed if a value is returned

def returnValue[T](check: ValueCheck[T]): TimedMatcher[T]

succeed if a value satisfying the ValueCheck is returned

succeed if a value satisfying the ValueCheck is returned

Extensions

Extensions

extension (timedMatcher: TimedMatcher[T])
def withValue[T](t: T)(using di: Diffable[T]): TimedMatcher[T]