|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.junit.runner.Runner
org.kuali.rice.test.runners.LoadTimeWeavableTestRunner
public class LoadTimeWeavableTestRunner
A JUnit test Runner which uses a custom classloader with a copy of the classpath and allows
for transformers to be added to the ClassLoader for load-time weaving. Useful when writing tests that use JPA with
EclipseLink since it depends upon load-time weaving.
Much of the code in this class was copied from the JUnit ParentRunner, BlockJUnit4ClassRunner, and TomcatInstrumentableClassLoader.
| Nested Class Summary | |
|---|---|
static class |
LoadTimeWeavableTestRunner.JUnitCustomClassLoader
|
| Constructor Summary | |
|---|---|
LoadTimeWeavableTestRunner(Class<?> testClass)
Constructs a new ParentRunner that will run @TestClass |
|
| Method Summary | |
|---|---|
protected org.junit.runners.model.Statement |
childrenInvoker(org.junit.runner.notification.RunNotifier notifier)
Returns a Statement: Call runChild(FrameworkMethod, RunNotifier)
on each object returned by getChildren() (subject to any imposed
filter and sort) |
protected org.junit.runners.model.Statement |
classBlock(org.junit.runner.notification.RunNotifier notifier)
Constructs a Statement to run all of the tests in the test class. |
protected List<org.junit.rules.TestRule> |
classRules()
|
protected void |
collectInitializationErrors(List<Throwable> errors)
Adds to errors a throwable for each problem noted with the test class (available from getTestClass()). |
protected List<org.junit.runners.model.FrameworkMethod> |
computeTestMethods()
Returns the methods that run tests. |
protected Object |
createTest()
Returns a new fixture for running a test. |
protected org.junit.runner.Description |
describeChild(org.junit.runners.model.FrameworkMethod method)
Returns a Description for child, which can be assumed to
be an element of the list returned by getChildren() |
void |
filter(org.junit.runner.manipulation.Filter filter)
|
protected List<org.junit.runners.model.FrameworkMethod> |
getChildren()
Returns a list of objects that define the children of this Runner. |
protected ClassLoader |
getCustomClassLoader()
|
org.junit.runner.Description |
getDescription()
|
protected String |
getName()
Returns a name used to describe this Runner |
protected Annotation[] |
getRunnerAnnotations()
|
org.junit.runners.model.TestClass |
getTestClass()
Returns a TestClass object wrapping the class to be executed. |
protected List<org.junit.rules.TestRule> |
getTestRules(Object target)
|
protected org.junit.runners.model.Statement |
methodBlock(org.junit.runners.model.FrameworkMethod method)
Returns a Statement that, when executed, either returns normally if method passes, or throws an exception if method fails. |
protected org.junit.runners.model.Statement |
methodInvoker(org.junit.runners.model.FrameworkMethod method,
Object test)
Returns a Statement that invokes method on test |
protected org.junit.runners.model.Statement |
possiblyExpectingExceptions(org.junit.runners.model.FrameworkMethod method,
Object test,
org.junit.runners.model.Statement next)
Deprecated. Will be private soon: use Rules instead |
protected List<org.junit.rules.MethodRule> |
rules(Object target)
|
void |
run(org.junit.runner.notification.RunNotifier notifier)
|
protected void |
runChild(org.junit.runners.model.FrameworkMethod method,
org.junit.runner.notification.RunNotifier notifier)
Runs the test corresponding to child, which can be assumed to be
an element of the list returned by getChildren(). |
protected void |
runLeaf(org.junit.runners.model.Statement statement,
org.junit.runner.Description description,
org.junit.runner.notification.RunNotifier notifier)
Runs a Statement that represents a leaf (aka atomic) test. |
void |
setScheduler(org.junit.runners.model.RunnerScheduler scheduler)
Sets a scheduler that determines the order and parallelization of children. |
protected void |
setTestMethod(Object test,
Method method)
Sets the Method on the test case if it is MethodAware |
protected void |
setTestName(Object test,
Method testMethod)
|
void |
sort(org.junit.runner.manipulation.Sorter sorter)
|
protected String |
testName(org.junit.runners.model.FrameworkMethod method)
Returns the name that describes method for Descriptions. |
protected void |
validateConstructor(List<Throwable> errors)
Adds to errors if the test class has more than one constructor,
or if the constructor takes parameters. |
protected void |
validateFields(List<Throwable> errors)
|
protected void |
validateInstanceMethods(List<Throwable> errors)
Deprecated. unused API, will go away in future version |
protected void |
validateNoNonStaticInnerClass(List<Throwable> errors)
|
protected void |
validateOnlyOneConstructor(List<Throwable> errors)
Adds to errors if the test class has more than one constructor
(do not override) |
protected void |
validatePublicVoidNoArgMethods(Class<? extends Annotation> annotation,
boolean isStatic,
List<Throwable> errors)
Adds to errors if any method in this class is annotated with
annotation, but:
is not public, or
takes parameters, or
returns something other than void, or
is static (given isStatic is false), or
is not static (given isStatic is true). |
protected void |
validateTestMethods(List<Throwable> errors)
Adds to errors for each method annotated with @Testthat
is not a public, void instance method with no arguments. |
protected void |
validateZeroArgConstructor(List<Throwable> errors)
Adds to errors if the test class's single constructor takes
parameters (do not override) |
protected org.junit.runners.model.Statement |
withAfterClasses(org.junit.runners.model.Statement statement)
Returns a Statement: run all non-overridden @AfterClass methods on this class
and superclasses before executing statement; all AfterClass methods are
always executed: exceptions thrown by previous steps are combined, if
necessary, with exceptions from AfterClass methods into a
MultipleFailureException. |
protected org.junit.runners.model.Statement |
withAfters(org.junit.runners.model.FrameworkMethod method,
Object target,
org.junit.runners.model.Statement statement)
Deprecated. Will be private soon: use Rules instead |
protected org.junit.runners.model.Statement |
withBeforeClasses(org.junit.runners.model.Statement statement)
Returns a Statement: run all non-overridden @BeforeClass methods on this class
and superclasses before executing statement; if any throws an
Exception, stop execution and pass the exception on. |
protected org.junit.runners.model.Statement |
withBefores(org.junit.runners.model.FrameworkMethod method,
Object target,
org.junit.runners.model.Statement statement)
Deprecated. Will be private soon: use Rules instead |
protected org.junit.runners.model.Statement |
withPotentialTimeout(org.junit.runners.model.FrameworkMethod method,
Object test,
org.junit.runners.model.Statement next)
Deprecated. Will be private soon: use Rules instead |
| 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 LoadTimeWeavableTestRunner(Class<?> testClass)
throws org.junit.runners.model.InitializationError
ParentRunner that will run @TestClass
org.junit.runners.model.InitializationError| Method Detail |
|---|
protected ClassLoader getCustomClassLoader()
protected void validatePublicVoidNoArgMethods(Class<? extends Annotation> annotation,
boolean isStatic,
List<Throwable> errors)
errors if any method in this class is annotated with
annotation, but:
isStatic is false), or
isStatic is true).
protected org.junit.runners.model.Statement classBlock(org.junit.runner.notification.RunNotifier notifier)
Statement to run all of the tests in the test class. Override to add pre-/post-processing.
Here is an outline of the implementation:
runChild(FrameworkMethod, RunNotifier) on each object returned by getChildren() (subject to any imposed filter and sort).@BeforeClass methods on this class
and superclasses before the previous step; if any throws an
Exception, stop execution and pass the exception on.
@AfterClass methods on this class
and superclasses before any of the previous steps; all AfterClass methods are
always executed: exceptions thrown by previous steps are combined, if
necessary, with exceptions from AfterClass methods into a
MultipleFailureException.
Statementprotected org.junit.runners.model.Statement withBeforeClasses(org.junit.runners.model.Statement statement)
Statement: run all non-overridden @BeforeClass methods on this class
and superclasses before executing statement; if any throws an
Exception, stop execution and pass the exception on.
protected org.junit.runners.model.Statement withAfterClasses(org.junit.runners.model.Statement statement)
Statement: run all non-overridden @AfterClass methods on this class
and superclasses before executing statement; all AfterClass methods are
always executed: exceptions thrown by previous steps are combined, if
necessary, with exceptions from AfterClass methods into a
MultipleFailureException.
protected List<org.junit.rules.TestRule> classRules()
ClassRules that can transform the block that runs
each method in the tested class.protected org.junit.runners.model.Statement childrenInvoker(org.junit.runner.notification.RunNotifier notifier)
Statement: Call runChild(FrameworkMethod, RunNotifier)
on each object returned by getChildren() (subject to any imposed
filter and sort)
protected String getName()
public final org.junit.runners.model.TestClass getTestClass()
TestClass object wrapping the class to be executed.
protected final void runLeaf(org.junit.runners.model.Statement statement,
org.junit.runner.Description description,
org.junit.runner.notification.RunNotifier notifier)
Statement that represents a leaf (aka atomic) test.
protected Annotation[] getRunnerAnnotations()
public org.junit.runner.Description getDescription()
getDescription in interface org.junit.runner.DescribablegetDescription in class org.junit.runner.Runnerpublic void run(org.junit.runner.notification.RunNotifier notifier)
run in class org.junit.runner.Runner
public void filter(org.junit.runner.manipulation.Filter filter)
throws org.junit.runner.manipulation.NoTestsRemainException
filter in interface org.junit.runner.manipulation.Filterableorg.junit.runner.manipulation.NoTestsRemainExceptionpublic void sort(org.junit.runner.manipulation.Sorter sorter)
sort in interface org.junit.runner.manipulation.Sortablepublic void setScheduler(org.junit.runners.model.RunnerScheduler scheduler)
protected void runChild(org.junit.runners.model.FrameworkMethod method,
org.junit.runner.notification.RunNotifier notifier)
child, which can be assumed to be
an element of the list returned by getChildren().
Subclasses are responsible for making sure that relevant test events are
reported through notifier
protected org.junit.runner.Description describeChild(org.junit.runners.model.FrameworkMethod method)
Description for child, which can be assumed to
be an element of the list returned by getChildren()
protected List<org.junit.runners.model.FrameworkMethod> getChildren()
protected List<org.junit.runners.model.FrameworkMethod> computeTestMethods()
@Test on this class and superclasses that
are not overridden.
protected void collectInitializationErrors(List<Throwable> errors)
errors a throwable for each problem noted with the test class (available from getTestClass()).
Default implementation adds an error for each method annotated with
@BeforeClass or @AfterClass that is not
public static void with no arguments.
protected void validateNoNonStaticInnerClass(List<Throwable> errors)
protected void validateConstructor(List<Throwable> errors)
errors if the test class has more than one constructor,
or if the constructor takes parameters. Override if a subclass requires
different validation rules.
protected void validateOnlyOneConstructor(List<Throwable> errors)
errors if the test class has more than one constructor
(do not override)
protected void validateZeroArgConstructor(List<Throwable> errors)
errors if the test class's single constructor takes
parameters (do not override)
@Deprecated protected void validateInstanceMethods(List<Throwable> errors)
errors for each method annotated with @Test,
@Before, or @After that is not a public, void instance
method with no arguments.
protected void validateFields(List<Throwable> errors)
protected void validateTestMethods(List<Throwable> errors)
errors for each method annotated with @Testthat
is not a public, void instance method with no arguments.
protected Object createTest()
throws Exception
Exception
protected void setTestMethod(Object test,
Method method)
throws Exception
Method on the test case if it is MethodAware
method - the current method to be runtest - the test instance
Exception
protected void setTestName(Object test,
Method testMethod)
throws Exception
Exceptionprotected String testName(org.junit.runners.model.FrameworkMethod method)
method for Descriptions.
Default implementation is the method's name
protected org.junit.runners.model.Statement methodBlock(org.junit.runners.model.FrameworkMethod method)
method passes, or throws an exception if method fails.
Here is an outline of the default implementation:
method on the result of createTest(), and
throw any exceptions thrown by either operation.
method's @Test annotation has the expecting attribute, return normally only if the previous step threw an
exception of the correct type, and throw an exception otherwise.
method's @Test annotation has the timeout attribute, throw an exception if the previous step takes more
than the specified number of milliseconds.
@Before methods on this class
and superclasses before any of the previous steps; if any throws an
Exception, stop execution and pass the exception on.
@After methods on this class
and superclasses after any of the previous steps; all After methods are
always executed: exceptions thrown by previous steps are combined, if
necessary, with exceptions from After methods into a
MultipleFailureException.
@Rule fields to modify the execution of the
above steps. A Rule may prevent all execution of the above steps,
or add additional behavior before and after, or modify thrown exceptions.
For more information, see TestRule
protected org.junit.runners.model.Statement methodInvoker(org.junit.runners.model.FrameworkMethod method,
Object test)
Statement that invokes method on test
@Deprecated
protected org.junit.runners.model.Statement possiblyExpectingExceptions(org.junit.runners.model.FrameworkMethod method,
Object test,
org.junit.runners.model.Statement next)
Statement: if method's @Test annotation
has the expecting attribute, return normally only if next
throws an exception of the correct type, and throw an exception
otherwise.
@Deprecated
protected org.junit.runners.model.Statement withPotentialTimeout(org.junit.runners.model.FrameworkMethod method,
Object test,
org.junit.runners.model.Statement next)
Statement: if method's @Test annotation
has the timeout attribute, throw an exception if next
takes more than the specified number of milliseconds.
@Deprecated
protected org.junit.runners.model.Statement withBefores(org.junit.runners.model.FrameworkMethod method,
Object target,
org.junit.runners.model.Statement statement)
Statement: run all non-overridden @Before
methods on this class and superclasses before running next; if
any throws an Exception, stop execution and pass the exception on.
@Deprecated
protected org.junit.runners.model.Statement withAfters(org.junit.runners.model.FrameworkMethod method,
Object target,
org.junit.runners.model.Statement statement)
Statement: run all non-overridden @After
methods on this class and superclasses before running next; all
After methods are always executed: exceptions thrown by previous steps
are combined, if necessary, with exceptions from After methods into a
MultipleFailureException.
protected List<org.junit.rules.MethodRule> rules(Object target)
target - the test case instance
protected List<org.junit.rules.TestRule> getTestRules(Object target)
target - the test case instance
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||