Hi,
Hmm I'm not sure what you really trying to do. But you cannot mock fields.
If it's *legacy* code, I would create a package protected method in your code that read the interface field. And in your test code, stub that method.
Something like:
ProductionCode implements ThirdPartyInterface {
// ...
public void theMethodThatDosBusinessStuff() {
// ...
String thing = readThirdPartyInterfaceField();
}
String readThirdPartyInterfaceField() {
return ThirdPartyInterface.theThing;
}
}
ProductionCodeTest {
public void my_code_should_do_the_following() {
// given
ProductionCode pcMock = mock(ProductionCode.class);
given(pcMock.readThirdPartyInterfaceField()).willReturn("something else");
// when
// then
}
}
Hope that helps,
--
Bryce