I am using Scalamock with ScalaTest, and am trying to mock a Java interface. I currently have:
private val _iface = mock [MyInterface]
now I want to do
_iface expects `someMethod returning "foo" once
But the compiler does not find expects
.
I imported org.scalatest._
and org.scalamock.scalatest._
. What else am I missing?
I think it should be something more like:
I think the expects arg is expecting the arg to the function
First of all, proxy mocks are not supported very well in ScalaMock 3, and I think they will be completely removed in ScalaMock 4. Do you really need to use proxy mocks instead macro mocks?
This should work:
If not, please check ScalaMock proxy mocks unit tests for more examples.
I use
scalaMock
version4.1.0
, this works for me:For some trait:
This should be put into a test
For more reading: scalaMock Guide, you'll find some examples there