0

单元测试用例在 awsStepFunctionsAsyncClient.startExecutionAsync 时通过,但对于 awsStepFunctionsAsyncClient.startExecution 失败

 @Test
public void testStateMachineExecutionSuccess(){
    IngestionWorkflowMetadata executionInputs = prepareStateMachineInputs();
    try{
        when(awsStepFunctionsAsyncClient.startExecution(any(StartExecutionRequest.class))).thenReturn(startExecutionResult);
        stepFunctionUtility.startExecution(executionInputs);
        ArgumentCaptor<StartExecutionRequest> requestCaptor = ArgumentCaptor.forClass(StartExecutionRequest.class);
        verify(awsStepFunctionsAsyncClient, times(1)).startExecution(requestCaptor.capture());
        Assert.assertEquals(EXPECTED_STEP_FUNCTION_ARN, requestCaptor.getValue().getStateMachineArn());
        Assert.assertEquals(EXECUTION_ID, requestCaptor.getValue().getName());
        Assert.assertEquals(INPUT_STRING, requestCaptor.getValue().getInput());
    } catch (Exception e){ failTheTest(); }
}
4

1 回答 1

0

我认为测试用例失败了

verify(awsStepFunctionsAsyncClient, times(1)).startExecution(requestCaptor.capture());

因为awsStepFunctionsAsyncClient.startExecution不是异步的。同步调用的执行时间times(0)和异步调用的执行时间。times(1)

于 2020-04-25T15:35:20.513 回答