How can I stub a method that use a ClassTag
in the implementation ?
class RefsFactory {
def get[I <: Item : ClassTag]: RefTo[I] = {
val itemType = implicitly[ClassTag[A]].runtimeClass.asInstanceOf[Class[A]]
// ...
}
}
This class is used a lot in our code and I would like to stub it to return others mock regarding the itemType
.
val factory = stub[RefsFactory]
val otherType = stub[RefTo[OtherType]]
(factory.get[OneType]) returns RefTo(new OneType())
(factory.get[OtherType]) returns otherType
Thanks
Aucun commentaire:
Enregistrer un commentaire