org.powermock.api.extension.listener
Class AnnotationEnabler

java.lang.Object
  extended by org.powermock.core.spi.support.AbstractPowerMockTestListenerBase
      extended by org.powermock.api.extension.listener.AnnotationEnabler
All Implemented Interfaces:
AnnotationEnablerListener, PowerMockTestListener
Direct Known Subclasses:
AnnotationEnabler

public class AnnotationEnabler
extends AbstractPowerMockTestListenerBase
implements AnnotationEnablerListener

Before each test method all fields annotated with Mock, MockNice or MockStrict will have mock objects created for them and injected to the fields.

It will only inject to fields that haven't been set before (i.e that are null).


Nested Class Summary
protected  class AnnotationEnabler.FieldInjector
           
 
Constructor Summary
AnnotationEnabler()
           
 
Method Summary
 void beforeTestMethod(Object testInstance, Method method, Object[] arguments)
           
 Class<? extends Annotation>[] getMockAnnotations()
           
protected  void injectDefaultMocks(Object testInstance)
           
protected  void injectNiceMocks(Object testInstance)
           
protected  void injectStrictMocks(Object testInstance)
           
 
Methods inherited from class org.powermock.core.spi.support.AbstractPowerMockTestListenerBase
afterTestMethod, afterTestSuiteEnded, beforeTestSuiteStarted
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.powermock.core.spi.PowerMockTestListener
afterTestMethod, afterTestSuiteEnded, beforeTestSuiteStarted
 

Constructor Detail

AnnotationEnabler

public AnnotationEnabler()
Method Detail

beforeTestMethod

public void beforeTestMethod(Object testInstance,
                             Method method,
                             Object[] arguments)
                      throws Exception
Specified by:
beforeTestMethod in interface PowerMockTestListener
Overrides:
beforeTestMethod in class AbstractPowerMockTestListenerBase
Throws:
Exception

injectStrictMocks

protected void injectStrictMocks(Object testInstance)
                          throws Exception
Throws:
Exception

injectNiceMocks

protected void injectNiceMocks(Object testInstance)
                        throws Exception
Throws:
Exception

injectDefaultMocks

protected void injectDefaultMocks(Object testInstance)
                           throws Exception
Throws:
Exception

getMockAnnotations

public Class<? extends Annotation>[] getMockAnnotations()
Specified by:
getMockAnnotations in interface AnnotationEnablerListener


Copyright © 2007-2013. All Rights Reserved.