dimanche 1 mai 2016

Mokito: How to Verify that a parameter is an Object with a specific parameter?

I have an EventBus that is posted as below

EventBus bus = EventBus.getDefault();
bus.post(new MyEvent("mystring", json));

I wanted to perform a unit test to ensure this bus has called a post function, with the MyEvent Object.

EventBus bus = mock(EventBus.class);
verify(bus).post(isA(MyEvent.class));

The above code works well. However, I also wanted to ensure "mystring" is passed to the MyEvent object during the instantiation. How could I achieve that?

Aucun commentaire:

Enregistrer un commentaire