Очень странное поведение в моем тесте.
public class MyTestclass {
@Before
void setUp(){
//do some setup, but hu i get called twice
//here i do some try catch thing to get the stacktrace...
}
void testOnlyOneTest(){
//make the testing, i get called only once
}
@After
void tearDown(){
//do some destroy things,... i get called twice too
}
}
StackTrace:
1)
MyTestClassTest.setUp() line: 85
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
Method.invoke(Object, Object...) line: 597
PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner(MethodRoadie).runBefores() line: 129
PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner(MethodRoadie).runBeforesThenTestThenAfters(Runnable) line: 93
PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(Method, Object, Runnable) line: 294
PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(Runnable) line: 282
PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner(MethodRoadie).runTest() line: 84
PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner(MethodRoadie).run() line: 49
PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(Method, RunNotifier) line: 207
PowerMockJUnit44RunnerDelegateImpl.runMethods(RunNotifier) line: 146
PowerMockJUnit44RunnerDelegateImpl$1.run() line: 120
ClassRoadie.runUnprotected() line: 34
ClassRoadie.runProtected() line: 44
PowerMockJUnit44RunnerDelegateImpl.run(RunNotifier) line: 118
JUnit4TestSuiteChunkerImpl.run(RunNotifier) line: 102
PowerMockRunner(AbstractCommonPowerMockRunner).run(RunNotifier) line: 53
JUnit4TestClassReference(JUnit4TestReference).run(TestExecution) line: 46
TestExecution.run(ITestReference[]) line: 38
RemoteTestRunner.runTests(String[], String, TestExecution) line: 467
RemoteTestRunner.runTests(TestExecution) line: 683
RemoteTestRunner.run() line: 390
RemoteTestRunner.main(String[]) line: 197
2)
MyTestClassTest.setUp() line: 85
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
Method.invoke(Object, Object...) line: 597
WhiteboxImpl.performMethodInvocation(Object, Method, Object...) line: 2014
WhiteboxImpl.doInvokeMethod(Object, Class<?>, String, Object...) line: 885
WhiteboxImpl.invokeMethod(Object, String, Object...) line: 713
Whitebox.invokeMethod(Object, String, Object...) line: 401
PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runTestMethod() line: 305
MethodRoadie$2.run() line: 86
PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner(MethodRoadie).runBeforesThenTestThenAfters(Runnable) line: 94
PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(Method, Object, Runnable) line: 294
PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(Runnable) line: 282
PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner(MethodRoadie).runTest() line: 84
PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner(MethodRoadie).run() line: 49
PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(Method, RunNotifier) line: 207
PowerMockJUnit44RunnerDelegateImpl.runMethods(RunNotifier) line: 146
PowerMockJUnit44RunnerDelegateImpl$1.run() line: 120
ClassRoadie.runUnprotected() line: 34
ClassRoadie.runProtected() line: 44
PowerMockJUnit44RunnerDelegateImpl.run(RunNotifier) line: 118
JUnit4TestSuiteChunkerImpl.run(RunNotifier) line: 102
PowerMockRunner(AbstractCommonPowerMockRunner).run(RunNotifier) line: 53
JUnit4TestClassReference(JUnit4TestReference).run(TestExecution) line: 46
TestExecution.run(ITestReference[]) line: 38
RemoteTestRunner.runTests(String[], String, TestExecution) line: 467
RemoteTestRunner.runTests(TestExecution) line: 683
RemoteTestRunner.run() line: 390
RemoteTestRunner.main(String[]) line: 197
Есть идеи, почему мой setUp вызывается дважды?
Я делаю какие-то насмешки вsetUp и после проверки я получаю ожидание 2 раза, вызванное 1 раз, так что мои тесты не пройдены.
Я использую Powermock 1.4.8, Junit 4.4 и инфраструктуру easymock