CatsEffectStubs

org.scalamock.stubs.CatsEffectStubs
trait CatsEffectStubs extends Stubs

Attributes

Experimental
true
Graph
Supertypes
trait Stubs
class Object
trait Matchable
class Any

Members list

Value members

Inherited methods

final def resetStubs(): Unit

Resets all recorded stub functions and arguments. This is useful if you want to create your stub once per suite. Note that in such case test cases should run sequentially

Resets all recorded stub functions and arguments. This is useful if you want to create your stub once per suite. Note that in such case test cases should run sequentially

Attributes

Inherited from:
Stubs
inline def stub[T]: Stub[T]

Generates an object of type T with possibility to record methods arguments and set-up method results

Generates an object of type T with possibility to record methods arguments and set-up method results

Attributes

Inherited from:
Stubs

Givens

Givens

given given_StubIO_IO: StubIO[[x, y] =>> IO[y]]

Inherited givens

given stubs: CreatedStubs

Collects all generated stubs

Collects all generated stubs

Attributes

Inherited from:
Stubs

Extensions

Extensions

extension [F](inline f: F)
inline def callsIO[Args <: NonEmptyTuple, R](using TupledFunction[F, Args => R]): IO[List[UntupledOne[Args]]]

Same as calls, but returns IO. You still can just use calls instead.

Same as calls, but returns IO. You still can just use calls instead.

Attributes

inline def returnsIO[E, A](using NotGiven[TupledFunction[F, _]])(value: IO[A])(using IO[A] <:< F): IO[Unit]

Same as returns without arguments, but returns IO

Same as returns without arguments, but returns IO

Attributes

inline def returnsIO[Args <: NonEmptyTuple, R](using TupledFunction[F, Args => IO[R]])(value: (UntupledOne[Args]) => IO[R]): IO[Unit]

Same as returns with arguments, but returns IO

Same as returns with arguments, but returns IO

Attributes

inline def timesIO: IO[Int]

Same as times, but returns IO. You still can just use times instead.

Same as times, but returns IO. You still can just use times instead.

Attributes

inline def timesIO[Args <: NonEmptyTuple, R](using TupledFunction[F, Args => R])(args: UntupledOne[Args]): IO[Int]

Same as times with concrete arguments, but returns IO. You still can just use times instead.

Same as times with concrete arguments, but returns IO. You still can just use times instead.

Attributes

Inherited extensions

extension [F](inline f: F)
inline def calls[Args <: NonEmptyTuple, R](using TupledFunction[F, Args => R]): List[UntupledOne[Args]]

Allows to get caught method arguments. For multiple arguments - returns them tupled. One list item per call.

Allows to get caught method arguments. For multiple arguments - returns them tupled. One list item per call.

 trait Foo:
   def foo1(x: Int): Int
   def foo2(x: Int, y: Int): Int

 val foo = stub[Foo]

 foo.foo1.returns(_ => 1)
 foo.foo2.returns(_ => 1)

 foo.foo1(2)
 foo.foo1(2)
 foo.foo2(0, 0)
 foo.foo2(1, 1)

 foo.foo1.calls // List(2, 2)
 foo.foo2.calls // List((0, 0), (1, 1))

Attributes

Inherited from:
Stubs
inline def isAfter(inline other: Any)(using log: CallLog): Boolean

Attributes

Inherited from:
Stubs
inline def isBefore(inline other: Any)(using log: CallLog): Boolean

Attributes

Inherited from:
Stubs
inline def returns[Args <: NonEmptyTuple, R](using TupledFunction[F, Args => R])(value: (UntupledOne[Args]) => R): Unit

Allows to set result for method with arguments.

Allows to set result for method with arguments.

 trait Foo:
   def foo1(x: Int): Int
   def foo2(x: Int, y: Int): Int

 val foo = stub[Foo]

 foo.foo1.returns:
   case 1 => 2
   case 2 => 5
   case _ => 0

 foo.foo2.returns:
   case (0, 0) => 1
   case _ => 0

 foo.foo1(2) // 5
 foo.foo2(0, 0) // 1

Attributes

Inherited from:
Stubs
inline def returns(using NotGiven[TupledFunction[F, _]])(value: F): Unit

Allows to set result for method without arguments.

Allows to set result for method without arguments.

 trait Foo:
   def foo0: Int

 val foo = stub[Foo]

 foo.foo0.returns(5)
 foo.foo0 // 5

Attributes

Inherited from:
Stubs
inline def times[Args <: NonEmptyTuple, R](using TupledFunction[F, Args => R])(args: UntupledOne[Args]): Int

Allows to get number of times method was executed with specified arguments. Multiple arguments should be provided as tuple.

Allows to get number of times method was executed with specified arguments. Multiple arguments should be provided as tuple.

 trait Foo:
   def foo1(x: Int): Int
   def foo2(x: Int, y: Int): Int

 val foo = stub[Foo]
 foo.foo1.returns(_ => 1)
 foo.foo2.returns(_ => 2)

 foo.foo1(3)
 foo.foo1(3)
 foo.foo2(1, 1)

 foo.foo1.times(1) // 0
 foo.foo1.times(3) // 2
 foo.foo2.times((1, 1)) // 1

Attributes

Inherited from:
Stubs
inline def times: Int

Allows to get number of times method was executed.

Allows to get number of times method was executed.

 trait Foo:
   def foo1(x: Int): Int

 val foo = stub[Foo]
 foo.foo1.returns(_ => 1)

 foo.foo1(2)
 foo.foo1(3)

 foo.foo1.times // 2

Attributes

Inherited from:
Stubs