package ziotest
Type Members
-
final
class
ExpectationException extends RuntimeException
Signals that mocks or stubs were called in an unexpected way.
-
trait
ScalamockZIOSpec extends ZIOSpecDefault with ScalamockZIOSpecSetup with ScalamockZIOSyntax
Base trait for tests on zio-test, using mocks.
Base trait for tests on zio-test, using mocks.
Basic example:
object ExampleSpec extends ScalamockZIOSpec { trait Service { def f(x: Int): UIO[String] } override def spec: Spec[TestEnvironment, Any] = suite("ExampleSpec")( test("succeed if function is invoked as expected") { for { _ <- ZIO.serviceWith[Service] { mock => (mock.f _).expects(42).returns(ZIO.succeed("-42")) } value <- ZIO.serviceWithZIO[Service](_.f(42)) } yield assertTrue(value == "-42") }, ).provide(mock[Service]) }
-
trait
ScalamockZIOSyntax extends ScalamockZIOSyntaxBase with MockConvertions
Allows configuring mocks outside of test classes, if needed:
Allows configuring mocks outside of test classes, if needed:
object MyUtils extends ScalamockZIOSyntax { def mockGetName = ZIO.serviceWith[UserService] { mock => (mock.getName _).expects(4).returnsZIO("Agent Smith") } }
Creating mocks and configuring Ordering can only be done in test code. The rest of the API is available through mixing in
ScalamockZIOSyntax. -
trait
SimplerZIOMockMigration extends AnyRef
Can simplify migration from zio-mock to scalamock.
Can simplify migration from zio-mock to scalamock. Not needed when writing tests on scalamock from scratch.