mercredi 27 avril 2016

EasyMock - Partial Mocking assigning the mock to specific field

In EasyMock, when using annotation @Mock You can set the to which member of the target object the mock will be assigned, using fieldName Example:

/*assign mock impl ONLY for myInterface2 member of tested object*/
@Mock(type= MockType.NICE, name="secondMember", fieldName = "myInterface2")
private MyInterfaceImpl myInterfaceMock; //step 1 for runner

This is very convenient as I don't need to create a special constructor to assign the internal members with mocked objects

Question: Is there such thing for partial mocking as well?

Many Thanks!

Aucun commentaire:

Enregistrer un commentaire