Hi, Here is the object to be mocked:public class Asset {String getData();void setData(String data);}In my business code (Repository.java), Asset.setData() is called to populate its data. In my test driver (RepositoryTest.java), I hope to test my business code using a mocked Asset object. Is there a way that I can call Asset.getData() to get the data that is set by the setter, setData()? Keep in mind that the setter is called in my business code. I wonder if I can mock Asset in my test code such that I can save the data value somewhere when setter is called. Then I can return it when the getter is called. Something like the following:--Asset asset = Mockito.mock(Asset.class);String savedData;Mockito.when(asset.setData($VALUE)).thenSaveTo(savedData);Mockito.when(asset.getData()).thenReturn(savedData);
Any help is appreciated.
You received this message because you are subscribed to the Google Groups "mockito" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mockito/-/sB7nqm6j5hgJ.
To post to this group, send email to moc...@googlegroups.com.
To unsubscribe from this group, send email to mockito+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mockito?hl=en.