|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.junit.runner.Runner
org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
org.junit.runners.BlockJUnit4ClassRunner
com.google.gwtmockito.GwtMockitoTestRunner
public class GwtMockitoTestRunner
A JUnit4 test runner that executes a test using GwtMockito. In addition to
the standard BlockJUnit4ClassRunner
features, a test executed with
GwtMockitoTestRunner
will behave as follows:
GwtMock
,
that field will be returned. Otherwise, if a provider is registered via
GwtMockito.useProviderForType(java.lang.Class>, com.google.gwtmockito.fakes.FakeProvider>)
, that provider will be used to
create a fake. Otherwise, a new mock instance will be returned. See
GwtMockito
for more information and for the set of fake
providers registered by default.
Element
to be mocked.
Widget
,
Composite
, and most subclasses of Panel
, will have their
methods replaced with no-ops to make it easier to test widgets extending
them. This behavior can be customized by overriding
getClassesToStub()
.
GwtMockito
Constructor Summary | |
---|---|
GwtMockitoTestRunner(Class<?> unitTestClass)
Creates a test runner which allows final GWT classes to be mocked. |
Method Summary | |
---|---|
protected List<String> |
getAdditionalClasspaths()
Returns a list of additional sources from which the classloader should read while running tests. |
protected Collection<Class<?>> |
getClassesToStub()
Returns a collection of classes whose non-abstract methods should always be replaced with no-ops. |
protected ClassLoader |
getParentClassloader()
Returns the classloader to use as the parent of GwtMockito's classloader. |
void |
run(RunNotifier notifier)
Runs the tests in this runner, ensuring that the custom GwtMockito classloader is installed as the context classloader. |
protected org.junit.runners.model.Statement |
withBefores(org.junit.runners.model.FrameworkMethod method,
Object target,
org.junit.runners.model.Statement statement)
Overridden to invoke GwtMockito.initMocks before starting each test. |
Methods inherited from class org.junit.runners.ParentRunner |
---|
childrenInvoker, classBlock, classRules, filter, getDescription, getName, getRunnerAnnotations, getTestClass, runLeaf, setScheduler, sort, validatePublicVoidNoArgMethods, withAfterClasses, withBeforeClasses |
Methods inherited from class org.junit.runner.Runner |
---|
testCount |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GwtMockitoTestRunner(Class<?> unitTestClass) throws org.junit.runners.model.InitializationError
org.junit.runners.model.InitializationError
Method Detail |
---|
protected Collection<Class<?>> getClassesToStub()
Composite
, DOM
UIObject
,
Widget
, and most subclasses of Panel
. This makes it much safer to test code
that uses or extends these types.
This list can be customized by defining a new test runner extending
GwtMockitoTestRunner
and overriding this method. This allows users to explicitly stub
out particular classes that are causing problems in tests. If you do this, you will probably
want to retain the classes that are stubbed here by doing something like this:
@Override protected Collection<Class<?>> getClassesToStub() { Collection<Class<?>> classes = super.getClassesToStub(); classes.add(MyBaseWidget.class); return classes; }
protected ClassLoader getParentClassloader()
GwtMockitoTestRunner
and overriding this method.
protected List<String> getAdditionalClasspaths()
GwtMockitoTestRunner
and overriding this method.
The entries in this list must be paths referencing a directory, jar, or zip file. The entries must not end with a "/". If an entry ends with "/*", then all jars matching the path name are included.
ClassPool.appendClassPath(String)
public void run(RunNotifier notifier)
run
in class ParentRunner<org.junit.runners.model.FrameworkMethod>
protected final org.junit.runners.model.Statement withBefores(org.junit.runners.model.FrameworkMethod method, Object target, org.junit.runners.model.Statement statement)
withBefores
in class BlockJUnit4ClassRunner
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |