我有一个带有executeOperation方法的operationService类,它接受一个数据库请求对象。这个数据库请求对象有4个属性,其中一个是operation。我想在基于数据库请求.operation字段调用operationService.executeOperation时返回不同的响应。请帮助我。这是我正在尝试实现的目标
when(operationService.executeOperation(anyDatabaserequest object with operation as 'DEMO')).thenReturn('DEMO_RESPONSE');
when(operationService.executeOperation(anyDatabaserequest object with operation as 'PILOT')).thenReturn('PILOT_RESPONSE');
1条答案
按热度按时间0g0grzrc1#
您可以使用Mockito.argThat执行以下操作: