Class AnnotationEnabler
java.lang.Object
org.powermock.core.spi.support.AbstractPowerMockTestListenerBase
org.powermock.api.extension.listener.AnnotationEnabler
- All Implemented Interfaces:
AnnotationEnablerListener, PowerMockTestListener
- Direct Known Subclasses:
AnnotationEnabler, AnnotationEnabler
public class AnnotationEnabler
extends AbstractPowerMockTestListenerBase
implements AnnotationEnablerListener
Before each test method all fields annotated with
Mock,
Mock or Mock have mock objects created for them
and injected to the fields. It will also delegate to a special implementation
of the InjectingAnnotationEngine in Mockito which inject's spies,
captors etc.
It will only inject to fields that haven't been set before (i.e that are
null).-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbeforeTestMethod(Object testInstance, Method method, Object[] arguments) Provides an empty implementation.Class<? extends Annotation>[]private voidinjectCaptor(Object testInstance) private voidinjectSpiesAndInjectToSetters(Object testInstance) private ObjectprocessAnnotationOn(org.mockito.Captor annotation, Field field) private voidstandardInject(Object testInstance) Methods inherited from class AbstractPowerMockTestListenerBase
afterTestMethod, afterTestSuiteEnded, beforeTestSuiteStartedMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface PowerMockTestListener
afterTestMethod, afterTestSuiteEnded, beforeTestSuiteStarted
-
Constructor Details
-
AnnotationEnabler
public AnnotationEnabler()
-
-
Method Details
-
beforeTestMethod
public void beforeTestMethod(Object testInstance, Method method, Object[] arguments) throws Exception Description copied from class:AbstractPowerMockTestListenerBaseProvides an empty implementation.- Specified by:
beforeTestMethodin interfacePowerMockTestListener- Overrides:
beforeTestMethodin classAbstractPowerMockTestListenerBase- Parameters:
testInstance- The test case instance.method- The test method that is currently executed.arguments- The arguments passed to the test method if any. May be an empty array but nevernull.- Throws:
Exception- If something unexpected occurs.
-
injectSpiesAndInjectToSetters
-
injectCaptor
-
standardInject
- Throws:
IllegalAccessException
-
getMockAnnotations
- Specified by:
getMockAnnotationsin interfaceAnnotationEnablerListener- Returns:
- The mock annotations considered by this annotation enabler.
-
processAnnotationOn
-