user1187135
user1187135

Reputation:

Scala mock polymorphic methods with implicit type tag

How to mock a polymorphic method with an implicit type tag parameter

val mockInterface = mock[SampleInterface]

trait SampleInterface {

  def fetchType[M <: Model : TypeTag]: Future[Unit]
}

Upvotes: 0

Views: 403

Answers (1)

user1187135
user1187135

Reputation:

(mockInterface.fetchType[SampleModel](_: TypeTag[SampleModel]))
    .expects(typeTag[SampleMode])
    .returning(Future.successful())

Upvotes: 1

Related Questions