类 InfraClassRule
- 所有已实现的接口:
org.junit.rules.TestRule
ApplicationClassRule is a custom JUnit TestRule that supports
class-level features of the TestContext Framework
in standard JUnit tests by means of the TestContextManager and
associated support classes and annotations.
In contrast to the JUnit4ClassRunner, Framework's rule-based JUnit support has the advantage
that it is independent of any Runner and
can therefore be combined with existing alternative runners like JUnit's
Parameterized or third-party runners such as the MockitoJUnitRunner.
In order to achieve the same functionality as the JUnit4ClassRunner,
however, a ApplicationClassRule must be combined with a InfraMethodRule,
since ApplicationClassRule only supports the class-level features of the
JUnit4ClassRunner.
Example Usage
public class ExampleInfraIntegrationTest {
@ClassRule
public static final ApplicationClassRule applicationClassRule = new ApplicationClassRule();
@Rule
public final ApplicationMethodRule applicationMethodRule = new ApplicationMethodRule();
// ...
}
The following list constitutes all annotations currently supported directly
or indirectly by ApplicationClassRule. (Note that additional annotations
may be supported by various
TestExecutionListener or
TestContextBootstrapper
implementations.)
NOTE: this class requires JUnit 4.12 or higher.
- 从以下版本开始:
- 4.0
- 作者:
- Sam Brannen, Philippe Marschall
- 另请参阅:
-
嵌套类概要
嵌套类 -
字段概要
字段修饰符和类型字段说明private static final cn.taketoday.logging.Loggerprivate static final Map<Class<?>,TestContextManager> Cache ofTestContextManagerskeyed by test class. -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明org.junit.runners.model.Statementapply(org.junit.runners.model.Statement base, org.junit.runner.Description description) Apply class-level features of the Infra TestContext Framework to the suppliedbasestatement.(专用程序包) static TestContextManagergetTestContextManager(Class<?> testClass) Get theTestContextManagerassociated with the supplied test class.private org.junit.runners.model.StatementwithAfterTestClassCallbacks(org.junit.runners.model.Statement next, TestContextManager testContextManager) Wrap the suppliedStatementwith aRunAfterTestClassCallbacksstatement.private org.junit.runners.model.StatementwithBeforeTestClassCallbacks(org.junit.runners.model.Statement next, TestContextManager testContextManager) Wrap the suppliedStatementwith aRunBeforeTestClassCallbacksstatement.private org.junit.runners.model.StatementwithProfileValueCheck(org.junit.runners.model.Statement next, Class<?> testClass) Wrap the suppliedStatementwith aProfileValueCheckerstatement.private org.junit.runners.model.StatementwithTestContextManagerCacheEviction(org.junit.runners.model.Statement next, Class<?> testClass) Wrap the suppliedStatementwith aTestContextManagerCacheEvictorstatement.
-
字段详细资料
-
logger
private static final cn.taketoday.logging.Logger logger -
testContextManagerCache
Cache ofTestContextManagerskeyed by test class.
-
-
构造器详细资料
-
InfraClassRule
public InfraClassRule()
-
-
方法详细资料
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description) Apply class-level features of the Infra TestContext Framework to the suppliedbasestatement.Specifically, this method retrieves the
TestContextManagerused by this rule and its associatedInfraMethodRuleand invokes thebeforeTestClass()andafterTestClass()methods on theTestContextManager.In addition, this method checks whether the test is enabled in the current execution environment. This prevents classes with a non-matching
@IfProfileValueannotation from running altogether, even skipping the execution ofbeforeTestClass()methods inTestExecutionListeners.- 指定者:
apply在接口中org.junit.rules.TestRule- 参数:
base- the baseStatementthat this rule should be applied todescription- aDescriptionof the current test execution- 返回:
- a statement that wraps the supplied
basewith class-level features of the TestContext Framework - 另请参阅:
-
getTestContextManager(java.lang.Class<?>)withBeforeTestClassCallbacks(org.junit.runners.model.Statement, cn.taketoday.test.context.TestContextManager)withAfterTestClassCallbacks(org.junit.runners.model.Statement, cn.taketoday.test.context.TestContextManager)withProfileValueCheck(org.junit.runners.model.Statement, java.lang.Class<?>)withTestContextManagerCacheEviction(org.junit.runners.model.Statement, java.lang.Class<?>)
-
withBeforeTestClassCallbacks
private org.junit.runners.model.Statement withBeforeTestClassCallbacks(org.junit.runners.model.Statement next, TestContextManager testContextManager) Wrap the suppliedStatementwith aRunBeforeTestClassCallbacksstatement. -
withAfterTestClassCallbacks
private org.junit.runners.model.Statement withAfterTestClassCallbacks(org.junit.runners.model.Statement next, TestContextManager testContextManager) Wrap the suppliedStatementwith aRunAfterTestClassCallbacksstatement. -
withProfileValueCheck
private org.junit.runners.model.Statement withProfileValueCheck(org.junit.runners.model.Statement next, Class<?> testClass) Wrap the suppliedStatementwith aProfileValueCheckerstatement.- 另请参阅:
-
withTestContextManagerCacheEviction
private org.junit.runners.model.Statement withTestContextManagerCacheEviction(org.junit.runners.model.Statement next, Class<?> testClass) Wrap the suppliedStatementwith aTestContextManagerCacheEvictorstatement. -
getTestContextManager
Get theTestContextManagerassociated with the supplied test class.- 参数:
testClass- the test class to be managed; nevernull
-