@Test
public void successfulHandshake(){
HandshakeImpl1Server handShake = new HandshakeImpl1Server();
handShake.setHttpStatus((short) 101);
authUnderTest.authenticate(callback);
doAnswer(invocation -> {
websocket.onOpen(handShake);
return null;
}).when(websocket).open();
verify(websocket,times(1)).send(any(String.class));
}
doAnswer is never called. Any ideas?
You need to stub your methods before, not after call to method under test.
Move doAnswer before call to authUnderTest.authenticate
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.