Say, my class Person
collaborates with other classes, Kettle
and Teacup
.
Person
has a method makeTea()
that should interact with Kettle
and Teacup
, each in different ways, in succession, but the order is unimportant.I would like to capture interactions between the Person
and Kettle
, and the interactions between Person
and Teacup
individually in two separate unit tests (let's call them testPersonFillsKettleWithWater
and testPersonPoursBoilingWaterIntoTeacup
)
To test the method makeTea()
it is not necessary to have Kettle
nor Teacup
. When testing for interactions with Kettle
, any interactions Teacup
don't matter.
With ScalaMock however if you do not declare expectations on Teacup
and yet some interactions occur, then Teacup
throws tantrums about "Unexpected method calls" etc.
In jMockit literature this is called setting 'strict' expectations. I would like to be able to omit specifying every expectation, and just test for certain interactions within one method. So the question is:
Does ScalaMock support non-strict expectations?
I'm aware of the mock stub 'method
syntax, but it is cumbersome to list out all the expectations that I find myself having to list.
This type of functionality is already in the preview release of ScalaMock3, but not in ScalaMock 2.4 I'm afraid.
I'm not planning any significant updates to the 2.x line. Having said that, what you're looking for shouldn't be too hard to add. Please feel free to add an issue and I'll see what I can do.
Alternatively if you fancy having a go your self (take a look at ProxyMockFactory
as a starting point) I'd be very happy to accept a pull request that adds this functionality.