我继承了一个不再起作用的 Junit 测试。它使用 PowerMock 1.4.12、Mockito 1.9.0 和 Junit 4.8.2。它正在工作一段时间但停止了,我正试图让它再次工作。
Wanted but not invoked:
clerkReviewPackageHelper.addSubmissionQueue(
<any>,
<any>,
<any>,
<any>
);
-> at icis.cr.approvefilingdetail.CRFilingToQueuesActionTest.test_post_handled_add_submission_queue(CRFilingToQueuesActionTest.java:47)
Actually, there were zero interactions with this mock.
at icis.cr.approvefilingdetail.CRFilingToQueuesActionTest.test_post_handled_add_submission_queue(CRFilingToQueuesActionTest.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:592)
at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:66)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:312)
at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:86)
at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:94)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:296)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:284)
at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:84)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:49)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:209)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:148)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:122)
at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34)
at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:120)
at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:102)
at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:53)
at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:42)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
这是此测试的代码:
@Test
public void test_post_handled_add_submission_queue() throws Exception {
when(request.getMethod()).thenReturn(BaseCRAction.POST);
when(sessionInfo.getSubmissionId()).thenReturn(SUBMISSION_ID);
when(crFilingToQueuesForm.getAction()).thenReturn(null);
crFilingToQueuesAction.executeProcess(actionMapping, crFilingToQueuesForm, request, response);
verify(clerkReviewPackageHelper, times(0)).removeSubmissionQueue(null);
**verify(clerkReviewPackageHelper).addSubmissionQueue(any(String.class), any(String.class), any(String.class), any(String.class));**
verify(actionMapping).findForward(eq(BaseCRAction.FORWARD_SUCCESS_REDIRECT));
}
这是它从异常行调用的方法:
public void addSubmissionQueue(String submissionId, String queueId, String reviewOn, String employeeId) throws BadDBConnection {
Session session = injector.inject();
session.executeNonSelectingCall(clerkReviewPackage.addQueue(submissionId, queueId, reviewOn, employeeId));
session.release();
}
任何帮助,将不胜感激!
谢谢,
汤姆