Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mock Generic Class #201

Closed
artvovc opened this issue Sep 13, 2017 · 1 comment
Closed

mock Generic Class #201

artvovc opened this issue Sep 13, 2017 · 1 comment

Comments

@artvovc
Copy link

artvovc commented Sep 13, 2017

Hi! i`m new in using ScalaMock. Need to create an mock or stub for an Generic Class Repository.

class FirstUT extends WordSpec with MustMatchers with MockFactory {
  "Some class" should {
    "do" in {
      val cl = stub[Repository[Wrap]]
      (cl.save _).when(*).returns("88585")
      val serviceOne = new ServiceOne(cl)
      serviceOne.save("88585") mustBe "8858588585"
    }
  }
}
Error:(7, 20) type mismatch;
 found   : A
 required: Wrap
      val cl = stub[Repository[Wrap]]
class ServiceOne(val repo:Repository[Wrap]){
  def save(str:String): String = {
    println("ServiceOne Save")
    repo.save(str) + str
  }
}
class Repository[A](val entity: A) {
  def save(str:String) = {
    println("saving")
    str + str
  }
}
case class Wrap()

If remove Repository constructor no errors occurs, but it is not answer.

@barkhorn
Copy link
Collaborator

Seems to be a duplicate of #170
I would appreciate if you use the form next time to fill in the which version of scalamock you used etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants