0
我對EasyMock來說相當新穎。我正在嘗試爲我的Spring WS Endpoint編寫一個EasyMock測試,並繼續遇到問題。詳情如下所列:EasyMock - 模擬對象的期望
端點:
測試:
@Before<BR>
public void setUp() throws JDOMException {<BR>
xPath = createNiceMock(XPath.class);<BR>
payload = createNiceMock(Element.class);<BR>
managementService = createStrictMock(UserManagementService.class);<BR>
serviceEndpoint = new UserManagementServiceEndpoint(managementService);
}
@Test
public void testUserCreationHandler() throws JDOMException {
expect(xPath.valueOf(payload)).andReturn("userName");
expect(xPath.valueOf(payload)).andReturn("loginName");
expect(xPath.valueOf(payload)).andReturn("eMail");
expect(xPath.valueOf(payload)).andReturn("region");
expect(xPath.valueOf(payload)).andReturn("department");
expect(xPath.valueOf(payload)).andReturn("businessUnit");
managementService.userCreate("userName", "loginName", "eMail",
"region", "department", "businessUnit");
expectLastCall();
replayAll();
serviceEndpoint.handleUserCreationRequest(payload);
verifyAll();
}
錯誤消息:
Failed tests:
testUserCreationHandler(com.xxx.usermanagement.endpoint.UserManagementServiceEndpoint
Test):
Expectation failure on verify:
valueOf(EasyMock for class org.jdom.Element): expected: 6, actual: 0
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0<BR><BR>
竟被我如果有人能幫助我,請欣賞。提前致謝。