简体   繁体   English

具有隐式类型标记的Scala模拟多态方法

[英]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]
}
(mockInterface.fetchType[SampleModel](_: TypeTag[SampleModel]))
    .expects(typeTag[SampleMode])
    .returning(Future.successful())

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM