cats.effect.kernel.testkit
package cats.effect.kernel.testkit
Type members
Classlikes
trait AsyncGeneratorsWithoutEvalShift[F[_]] extends GenTemporalGenerators[F, Throwable] with SyncGenerators[F]
- Source:
- Generators.scala
trait MonadErrorGenerators[F[_], E] extends MonadGenerators[F] with ApplicativeErrorGenerators[F, E]
- Source:
- Generators.scala
A scala.concurrent.ExecutionContext implementation that can simulate async boundaries and
time passage, useful for law testing purposes. This is intended primarily for datatype
implementors. Most end-users will be better served by the cats.effect.testkit.TestControl
utility, rather than using TestContext
directly.
A scala.concurrent.ExecutionContext implementation that can simulate async boundaries and
time passage, useful for law testing purposes. This is intended primarily for datatype
implementors. Most end-users will be better served by the cats.effect.testkit.TestControl
utility, rather than using TestContext
directly.
Usage for simulating an ExecutionContext
):
implicit val ec = TestContext()
ec.execute(new Runnable { def run() = println("task1") })
ex.execute(new Runnable {
def run() = {
println("outer")
ec.execute(new Runnable {
def run() = println("inner")
})
}
})
// Nothing executes until `tick` gets called
ec.tick()
// Testing the resulting state
assert(ec.state.tasks.isEmpty)
assert(ec.state.lastReportedFailure == None)
- Companion:
- object
- Source:
- TestContext.scala