I have seen many articles on how to mock the method in the case class when testing with scalamock.
However, sometimes I need to mock only one field. For example when I'm testing a very narrow workflow.
I thought that stub[Type].copy(f = "1")
would do a trick, but it returns only null
.
Neither can you mock the field as if it was a method:
val x = mock[Type]
( x.f _ ).when().then("1")
This won't compile as well.
What is the workaround in this situation? What is the best practice in this situation? Should I really define the whole case class fields that I don't need to test?