Mockito.doNothing()仍在运行



我正在尝试测试一些小代码。我不想测试其中一个方法,并使用了Mockito.doNothing(),但这个方法仍然在运行。我该怎么做?

 protected EncoderClientCommandEventHandler clientCommandEventHandlerProcessStop = new EncoderClientCommand.EncoderClientCommandEventHandler() {
    @Override
    public void onCommandPerformed(
        EncoderClientCommand clientCommand) {
      setWatcherActivated(false);
      buttonsBackToNormal();
    }
  };
  protected void processStop() {
    EncoderServerCommand serverCommand = new EncoderServerCommand();
    serverCommand.setAction(EncoderAction.STOP);
    checkAndSetExtension();
    serverCommand.setKey(getArchiveJobKey());
    getCommandFacade().performCommand(
        serverCommand,
        EncoderClientCommand.getType(),
        clientCommandEventHandlerProcessStop);
  }
  @Test
  public void testClientCommandEventHandlerProcessStop() {
    EncoderClientCommand encoderClientCommand = mock(EncoderClientCommand.class);
    Mockito.doNothing().when(encoderCompositeSpy).buttonsBackToNormal();
    when(encoderCompositeSpy.isWatcherActivated()).thenReturn(false);
    encoderCompositeSpy.clientCommandEventHandlerProcessStop.onCommandPerformed(encoderClientCommand);

我发现了问题。其中一个变量已经在buttonsBackNormal()中进行了模拟。

相关内容

  • 没有找到相关文章

最新更新