-
Notifications
You must be signed in to change notification settings - Fork 584
AnnotationBasedMocking
Arthur Zagretdinov edited this page Jun 15, 2017
·
2 revisions
- Use
@PowerMockTestListener(AnnotationEnabler.class)
at the class-level of your test to enable the annotation support. - Use
@Mock
on a field to allow PowerMock to create and inject a mock of the same type as the field. - Use
@MockNice
on a field to allow PowerMock to create and inject a nice mock of the same type as the fieldprivate constructor. - Use
@MockStrict
on a field to allow PowerMock to create and inject a strict mock of the same type as the field - Use
@Mock("methodName")
on a field to allow PowerMock to create and inject a partial mock of the same type as the field mocking only the method calledmethodName
. This also work for@MockNice
and@MockStrict
.