Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why i can't mock a method call for super class ? #1164

Open
lingluan533 opened this issue Aug 8, 2023 · 1 comment
Open

Why i can't mock a method call for super class ? #1164

lingluan533 opened this issue Aug 8, 2023 · 1 comment

Comments

@lingluan533
Copy link

Hey,

i hava a method inputTxt(ParamType param) in Father class ,and i invoke inputTxt in Child class, i want to test Child class and i want to mock inputTxt method. How can i do ,i have tried many plan but not get expected value.
like :
Method inputEnTxt = PowerMockito.method(Father.class, "inputTxt", ParamaType.class);
PowerMockito.replace(inputTxt).with(new InvocationHandler() {
@OverRide
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return true;
}
});

it's still to call real method inputTxt.

@werson
Copy link

werson commented Nov 6, 2023

@RunWith(PowerMockRunner.class)
@PrepareForTest({Father.class})
Add them to the test class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants