저는 java, unit-testing 및 mockito를 처음 사용하지만 클래스에서 무언가를 테스트하고 싶습니다. 내가 테스트 할Mockito 테스트 덮어 쓰는 void 메서드
등급 :
abstract class Irc {
Command received(String data) {
// parsing
receivedCommand(prefix, command, parameters, trailing, tags);
return new Command(prefix, command, parameters, trailing, tags);
}
private void receivedCommand(String prefix, String command, String[] parameters, String trailing, Map<String, String> tags) {
String nick = getNickFromPrefix(prefix);
parsed(prefix, command, parameters, trailing);
if (command.equals("MODE")) {
if (parameters.length == 3) {
String chan = parameters[0];
String mode = parameters[1];
String name = parameters[2];
if (mode.length() == 2) {
String modeChar = mode.substring(1, 2);
if (mode.startsWith("+")) {
onModeChange(chan, name, true, modeChar, prefix);
} else if (mode.startsWith("-")) {
onModeChange(chan, name, false, modeChar, prefix);
}
}
}
return;
}
}
void onModeChange(String channel, String nick, boolean modeAdded, String mode, String prefix) {
}
}
편집 : 나는 received
가 호출 된 후 onModeChange
가 호출되어 있는지 확인하려면 .
지금까지이 내용 : when
가 작동하지만 verify
이 Actually, there were zero interactions with this mock.
어쩌면 당신이 게시물 https://stackoverflow.com/questions/1087339/using-mockito-to-test-abstract-classes에 보일 것입니다 – Piotr0123456
나는 몇 가지 문제가 있었다 formating, 나는 나의 포스트를 새롭게했다. – SUNflOw1991
왜 내가 -5 표를 얻었습니까? 내가 뭔가 잘못 됐니? – SUNflOw1991