EasyMock中意外的方法调用

时间:2019-01-25 09:46:32

标签: java easymock

我有一些代码:

@Test
    public void testHandlePostInterruptActions() {
postInterruptActionsExecutor.takeActionAfterWFInterrupted(getWfStepExecutionDetails().get(0), pAccId, interrupt, wfStep);
        expectLastCall();
        replay(postInterruptActionsExecutor);
    orchestrator.handlePostInterruptActions(interrupt);
    EasyMock.verify(postInterruptActionsExecutor, orcDepProvider, pwaDAO, pdh);
}

内部测试班:

[junit]   Unexpected method call PostInterruptActionsExecutor.takeActionAfterWFInterrupted(WorkflowStepExecutionDetails(wfStepName=null, wfId=4c46f286-c368-49e7-a7db-30c39d72d1b8, planId=null, resultBranch=null, wfStepStatus=null, creationTime=null, workflowStepRequirements=null, attemptCount=null, parentWfStepId=null, wfStepType=null, wfStepDependencyResponseId=null), "81bd1b7e-7433-4116-bf46-52318b493e93", [com.amazon.verificationorchestration.plan.Interrupt@9e781b8e], com.amazon.verificationorchestration.plan.InitiateTokenVerificationWorkflowStep@860a7ec9):
[junit]     PostInterruptActionsExecutor.takeActionAfterWFInterrupted(WorkflowStepExecutionDetails(wfStepName=null, wfId=4c46f286-c368-49e7-a7db-30c39d72d1b8, planId=null, resultBranch=null, wfStepStatus=null, creationTime=null, workflowStepRequirements=null, attemptCount=null, parentWfStepId=null, wfStepType=null, wfStepDependencyResponseId=null), "81bd1b7e-7433-4116-bf46-52318b493e93", [com.amazon.verificationorchestration.plan.Interrupt@9e781b8e], com.amazon.verificationorchestration.plan.InitiateTokenVerificationWorkflowStep@860a7ec9): expected: 1, actual: 0

由于参数不匹配而导致测试失败:

java -Dhudson.model.DirectoryBrowserSupport.CSP="sandbox allow-scripts allow-popups allow-popups-to-escape-sandbox; style-src 'unsafe-inline' *;" -Dsvnkit.http.sslProtocols=TLSv1 -jar C:/server/Jenkins.war --httpPort=8280

即使预期的调用和实际的调用包含相同的参数测试仍然失败。我在这里想念什么吗?

1 个答案:

答案 0 :(得分:0)

我认为您使用的是EasyMock的旧版本,否则消息将更加清晰。是哪个版本?

EasyMock使用eq()作为默认匹配器。在这里,我怀疑toString()的{​​{1}}使它们看起来相同,但是WorkflowStepExecutionDetails可能不会被覆盖。而且由于它们是两个不同的实例,因此它们与Object.equals(即Object.equals)不同。