tags:

views:

882

answers:

1

Hi,

I have a method call which I want to mock with mockito. To start with I have created and injected an instance of an object on which the method will be called. My aim is to verify one of the object in method call.

Is there a way that mockito allows you to assert or verify the object and it's attributes when the mock method is called?

example

Mockito.verify(mockedObject).someMethodOnMockedObject(Mockito.anyObject())

Instead of doing anyObject() i want to check that argument object contains some particular fields

Mockito.verify(mockedObject).someMethodOnMockedObject(Mockito.compareWithThisObject())

+3  A: 

http://sites.google.com/a/pintailconsultingllc.com/java/argument-matching-with-mockito

This link provides a working example. I was able to solve it with same strategy.

Priyank