You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Powermock/mockito is able to do the same as we do with Aspectj without any special command line, making the usage easier. It seems to do bytecode manipulation to do the work.
Instead of doing the same, maybe powermock + mockito can be used instead.
After somehow discovered all the annotation, generate code that calls:
This looks really nice, but I can't get it to work outside a unit test. Powermock requires a test class that's annotated with @RunWith(PowerMockRunner.class) and @PrepareForTest(ExampleRecordedObject.class) (in our case).
I've tried taking the PowerMockRunner apart to get it to work without being inside a test context, but AbstractTestSuiteChunkerImpl is pretty complex and hard to pull apart.
The approach looks real cool, so I hope we find a way to use it.
MockClassLoader is being used, but what the RunWith(PowerMockRunner) does seems to be to run the classes in a new thread with MockClassLoader as the class loader. It will take a long time to extract the parts.
Powermock/mockito is able to do the same as we do with Aspectj without any special command line, making the usage easier. It seems to do bytecode manipulation to do the work.
Instead of doing the same, maybe powermock + mockito can be used instead.
After somehow discovered all the annotation, generate code that calls:
For Record:
ClassToRecord classToRecord(new ClassToRecord());
ClassToRecord classUnderTestSpy = PowerMockito.spy(classToRecord);
whenNew(ClassToRecord.class).withNoArguments().thenReturn(classUnderTestSpy);
Mockito.when(classUnderTest.methodToMock()).thenAnswer(recordingAnswer);
An answer class receives parameters so we can record and then call the real class:
http://mockito.googlecode.com/svn/branches/1.7/javadoc/org/mockito/stubbing/Answer.html#answer%28org.mockito.invocation.InvocationOnMock%29
Dependency:
Do the same. On playback we can let answer class return recorded values instead.
The text was updated successfully, but these errors were encountered: