I have object Panel inside is Methods
protected Confirmation confim() {
Confirmation confirmation = new Confirmation() {
@Override
public void onConfirm() {
doCancel();
}
};
return confirmation;
}
protected void doCancel() {
....
}
and i need to check That confirm() call doCancel Method
My Test
@Test
public void test() {
Panel panel = Mockito.mock(Panel.class);
Mockito.doCallRealMethod().when(panel).confirm();
Mockito.doCallRealMethod().when(panel).cancel();
panel.confirm();
Mockito.verify(panel).cancel();
}`
The problem is that cancel() is never called... maybe it is because OnConfirm() is an overidden method and it takes a mock... or something... Can some one help how to test?
P.S. Panel must be Mocked.
problem was that o dont call panel.confirm().onConfirm(); this is stupid mistake.. so please remove this Question..
@Test
public void test() {
Panel panel = Mockito.mock(Panel.class);
Mockito.doCallRealMethod().when(panel).confirm();
Mockito.doCallRealMethod().when(panel).cancel();
panel.confirm().onConfirm();
Mockito.verify(panel).cancel();
}`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With