Skip to content

Use powermock/mockito technology as alternative to Aspectj #16

@mkotsbak

Description

@mkotsbak

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions