我使用带的Mockito斯卡拉,和我有一个看起来像这样的时候()语句:我可以检查一个Mockito when()语句中的参数吗?
when(iService.find(any[InventoryRequest])).thenReturn(invResponse)
这工作,但我想作一堆,这些变化是基于返回响应InventoryRequest内的有效载荷,它是一个案例类。
所以我会做这样的事情:
when(iService.find(any[InventoryRequest] and therequest.field==1)).thenReturn(invResponse1)
when(iService.find(any[InventoryRequest] and therequest.field==2)).thenReturn(invResponse2)
...等等。基本上看传递的参数,并基于它返回不同的响应。
是的,我可以通过创建一大堆不同的测试类来做到这一点,但我想知道如果Mockito有我在这里寻找的功能。