public class UnitilsBootBlockJUnit4ClassRunner extends org.junit.runners.BlockJUnit4ClassRunner
| 限定符和类型 | 字段和说明 |
|---|---|
protected Object |
test |
protected org.unitils.core.TestListener |
unitilsTestListener |
| 构造器和说明 |
|---|
UnitilsBootBlockJUnit4ClassRunner(Class<?> clazz)
Construct a new
UnitilsBootBlockJUnit4ClassRunner and initialize a
TestContextManager to provide Spring testing functionality to
standard JUnit tests. |
| 限定符和类型 | 方法和说明 |
|---|---|
protected org.junit.runners.model.Statement |
classBlock(org.junit.runner.notification.RunNotifier notifier) |
protected Object |
createTest()
Delegate to the parent implementation for creating the test instance and
then allow the
TestContextManager to
prepare the test instance before returning it. |
protected org.springframework.test.context.TestContextManager |
createTestContextManager(Class<?> clazz)
Create a new
TestContextManager for the supplied test class. |
org.junit.runner.Description |
getDescription()
Return a description suitable for an ignored test class if the test is
disabled via
@IfProfileValue at the class-level, and
otherwise delegate to the parent implementation. |
protected Class<? extends Throwable> |
getExpectedException(org.junit.runners.model.FrameworkMethod frameworkMethod)
Get the
exception that the supplied test method is expected to throw. |
protected org.springframework.test.context.TestContextManager |
getTestContextManager()
Get the
TestContextManager associated with this runner. |
protected org.unitils.core.TestListener |
getUnitilsTestListener() |
protected boolean |
isTestMethodIgnored(org.junit.runners.model.FrameworkMethod frameworkMethod)
Return
true if @Ignore is present for the supplied
test method or if the test method is disabled
via @IfProfileValue. |
protected org.junit.runners.model.Statement |
methodBlock(org.junit.runners.model.FrameworkMethod frameworkMethod)
Augment the default JUnit behavior
with potential repeats of the entire
execution chain.
|
protected org.junit.runners.model.Statement |
methodInvoker(org.junit.runners.model.FrameworkMethod method,
Object test) |
protected org.junit.runners.model.Statement |
possiblyExpectingExceptions(org.junit.runners.model.FrameworkMethod frameworkMethod,
Object testInstance,
org.junit.runners.model.Statement next)
Perform the same logic as
BlockJUnit4ClassRunner.possiblyExpectingExceptions(FrameworkMethod, Object, Statement)
except that the expected exception is retrieved using
getExpectedException(FrameworkMethod). |
void |
run(org.junit.runner.notification.RunNotifier notifier)
Check whether the test is enabled in the current execution environment.
|
protected void |
runChild(org.junit.runners.model.FrameworkMethod frameworkMethod,
org.junit.runner.notification.RunNotifier notifier)
Perform the same logic as
BlockJUnit4ClassRunner.runChild(FrameworkMethod, RunNotifier),
except that tests are determined to be ignored by
isTestMethodIgnored(FrameworkMethod). |
protected org.junit.runners.model.Statement |
withAfterClasses(org.junit.runners.model.Statement statement)
Wrap the
Statement returned by the parent implementation with a
RunAfterTestClassCallbacks statement, thus preserving the default
JUnit functionality while adding support for the Spring TestContext Framework. |
protected org.junit.runners.model.Statement |
withAfters(org.junit.runners.model.FrameworkMethod frameworkMethod,
Object testInstance,
org.junit.runners.model.Statement statement)
Wrap the
Statement returned by the parent implementation with a
RunAfterTestMethodCallbacks statement, thus preserving the
default functionality while adding support for the Spring TestContext
Framework. |
protected org.junit.runners.model.Statement |
withBeforeClasses(org.junit.runners.model.Statement statement)
Wrap the
Statement returned by the parent implementation with a
RunBeforeTestClassCallbacks statement, thus preserving the
default JUnit functionality while adding support for the Spring TestContext
Framework. |
protected org.junit.runners.model.Statement |
withBefores(org.junit.runners.model.FrameworkMethod frameworkMethod,
Object testInstance,
org.junit.runners.model.Statement statement)
Wrap the
Statement returned by the parent implementation with a
RunBeforeTestMethodCallbacks statement, thus preserving the
default functionality while adding support for the Spring TestContext
Framework. |
protected org.junit.runners.model.Statement |
withPotentialRepeat(org.junit.runners.model.FrameworkMethod frameworkMethod,
Object testInstance,
org.junit.runners.model.Statement next)
Wrap the supplied
Statement with a SpringRepeat statement. |
collectInitializationErrors, computeTestMethods, describeChild, getChildren, getTestRules, isIgnored, rules, testName, validateConstructor, validateFields, validateInstanceMethods, validateNoNonStaticInnerClass, validateOnlyOneConstructor, validateTestMethods, validateZeroArgConstructor, withPotentialTimeoutprotected org.unitils.core.TestListener unitilsTestListener
public UnitilsBootBlockJUnit4ClassRunner(Class<?> clazz) throws org.junit.runners.model.InitializationError
UnitilsBootBlockJUnit4ClassRunner and initialize a
TestContextManager to provide Spring testing functionality to
standard JUnit tests.clazz - the test class to be runorg.junit.runners.model.InitializationErrorcreateTestContextManager(Class)protected org.unitils.core.TestListener getUnitilsTestListener()
protected org.junit.runners.model.Statement methodInvoker(org.junit.runners.model.FrameworkMethod method, Object test)
methodInvoker 在类中 org.junit.runners.BlockJUnit4ClassRunnerprotected org.junit.runners.model.Statement classBlock(org.junit.runner.notification.RunNotifier notifier)
classBlock 在类中 org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>protected org.springframework.test.context.TestContextManager createTestContextManager(Class<?> clazz)
TestContextManager for the supplied test class.
Can be overridden by subclasses.
clazz - the test class to be managedprotected final org.springframework.test.context.TestContextManager getTestContextManager()
TestContextManager associated with this runner.public org.junit.runner.Description getDescription()
@IfProfileValue at the class-level, and
otherwise delegate to the parent implementation.getDescription 在接口中 org.junit.runner.DescribablegetDescription 在类中 org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>ProfileValueUtils.isTestEnabledInThisEnvironment(Class)public void run(org.junit.runner.notification.RunNotifier notifier)
This prevents classes with a non-matching @IfProfileValue
annotation from running altogether, even skipping the execution of
prepareTestInstance() methods in TestExecutionListeners.
run 在类中 org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>ProfileValueUtils.isTestEnabledInThisEnvironment(Class),
IfProfileValue,
TestExecutionListenerprotected org.junit.runners.model.Statement withBeforeClasses(org.junit.runners.model.Statement statement)
Statement returned by the parent implementation with a
RunBeforeTestClassCallbacks statement, thus preserving the
default JUnit functionality while adding support for the Spring TestContext
Framework.withBeforeClasses 在类中 org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>RunBeforeTestClassCallbacksprotected org.junit.runners.model.Statement withAfterClasses(org.junit.runners.model.Statement statement)
Statement returned by the parent implementation with a
RunAfterTestClassCallbacks statement, thus preserving the default
JUnit functionality while adding support for the Spring TestContext Framework.withAfterClasses 在类中 org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>RunAfterTestClassCallbacksprotected Object createTest() throws Exception
TestContextManager to
prepare the test instance before returning it.createTest 在类中 org.junit.runners.BlockJUnit4ClassRunnerExceptionTestContextManager.prepareTestInstance(java.lang.Object)protected void runChild(org.junit.runners.model.FrameworkMethod frameworkMethod, org.junit.runner.notification.RunNotifier notifier)
BlockJUnit4ClassRunner.runChild(FrameworkMethod, RunNotifier),
except that tests are determined to be ignored by
isTestMethodIgnored(FrameworkMethod).runChild 在类中 org.junit.runners.BlockJUnit4ClassRunnerprotected org.junit.runners.model.Statement methodBlock(org.junit.runners.model.FrameworkMethod frameworkMethod)
Furthermore, support for timeouts has been moved down the execution
chain in order to include execution of @Before
and @After methods within the timed execution.
Note that this differs from the default JUnit behavior of executing
@Before and @After methods in the main thread while
executing the actual test method in a separate thread. Thus, the net
effect is that @Before and @After methods will be
executed in the same thread as the test method. As a consequence,
JUnit-specified timeouts will work fine in combination with Spring
transactions. However, JUnit-specific timeouts still differ from
Spring-specific timeouts in that the former execute in a separate
thread while the latter simply execute in the main thread (like regular
tests).
methodBlock 在类中 org.junit.runners.BlockJUnit4ClassRunnerpossiblyExpectingExceptions(FrameworkMethod, Object, Statement),
withBefores(FrameworkMethod, Object, Statement),
withAfters(FrameworkMethod, Object, Statement),
withRulesReflectively(FrameworkMethod, Object, Statement),
withPotentialRepeat(FrameworkMethod, Object, Statement),
BlockJUnit4ClassRunner.withPotentialTimeout(FrameworkMethod, Object, Statement)protected boolean isTestMethodIgnored(org.junit.runners.model.FrameworkMethod frameworkMethod)
true if @Ignore is present for the supplied
test method or if the test method is disabled
via @IfProfileValue.ProfileValueUtils.isTestEnabledInThisEnvironment(Method, Class)protected org.junit.runners.model.Statement possiblyExpectingExceptions(org.junit.runners.model.FrameworkMethod frameworkMethod, Object testInstance, org.junit.runners.model.Statement next)
BlockJUnit4ClassRunner.possiblyExpectingExceptions(FrameworkMethod, Object, Statement)
except that the expected exception is retrieved using
getExpectedException(FrameworkMethod).possiblyExpectingExceptions 在类中 org.junit.runners.BlockJUnit4ClassRunnerprotected Class<? extends Throwable> getExpectedException(org.junit.runners.model.FrameworkMethod frameworkMethod)
exception that the supplied test method is expected to throw.
Supports JUnit's @Test(expected=...) annotation.
Can be overridden by subclasses.
null if none was specifiedprotected org.junit.runners.model.Statement withBefores(org.junit.runners.model.FrameworkMethod frameworkMethod, Object testInstance, org.junit.runners.model.Statement statement)
Statement returned by the parent implementation with a
RunBeforeTestMethodCallbacks statement, thus preserving the
default functionality while adding support for the Spring TestContext
Framework.withBefores 在类中 org.junit.runners.BlockJUnit4ClassRunnerRunBeforeTestMethodCallbacksprotected org.junit.runners.model.Statement withAfters(org.junit.runners.model.FrameworkMethod frameworkMethod, Object testInstance, org.junit.runners.model.Statement statement)
Statement returned by the parent implementation with a
RunAfterTestMethodCallbacks statement, thus preserving the
default functionality while adding support for the Spring TestContext
Framework.withAfters 在类中 org.junit.runners.BlockJUnit4ClassRunnerRunAfterTestMethodCallbacksprotected org.junit.runners.model.Statement withPotentialRepeat(org.junit.runners.model.FrameworkMethod frameworkMethod, Object testInstance, org.junit.runners.model.Statement next)
Statement with a SpringRepeat statement.
Supports Spring's @Repeat
annotation.
TestAnnotationUtils.getRepeatCount(Method),
SpringRepeatCopyright © 2018. All rights reserved.