本文整理汇总了Java中org.junit.rules.TestRule.apply方法的典型用法代码示例。如果您正苦于以下问题:Java TestRule.apply方法的具体用法?Java TestRule.apply怎么用?Java TestRule.apply使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.junit.rules.TestRule
的用法示例。
在下文中一共展示了TestRule.apply方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyRuleToLastStatement
import org.junit.rules.TestRule; //导入方法依赖的package包/类
@Override
protected Statement applyRuleToLastStatement(final Method method, final Object testInstance, Field field,
final LastRuleTestExecutorStatement lastStatement) throws IllegalAccessException {
final Object fieldValue = field.get(testInstance);
final Statement statement;
if (fieldValue instanceof MethodRule) {
// the MethodRule is known by junit 4.9 -> delegate to super-class
statement = super.applyRuleToLastStatement(method, testInstance, field, lastStatement);
} else if (fieldValue instanceof TestRule){
TestRule rule = (TestRule) fieldValue;
statement = rule.apply(lastStatement, description);
} else {
throw new IllegalStateException("Can only handle MethodRule and TestRule");
}
return statement;
}
示例2: apply
import org.junit.rules.TestRule; //导入方法依赖的package包/类
@Override
public Statement apply(Statement base, final Description description) {
for (TestRule each : this.rules) {
base = each.apply(base, description);
}
return base;
}
示例3: apply
import org.junit.rules.TestRule; //导入方法依赖的package包/类
/**
* Takes all the rules in {@link #testRules()} and applies them to this Test Rule.
* This is essential because the composite rule may depend on these rules being executed.
*/
@Override
public final Statement apply(Statement base, Description description) {
base = innerResource.apply(base, description);
for (TestRule each : testRules()) {
base = each.apply(base, description);
}
return base;
}
示例4: applyAll
import org.junit.rules.TestRule; //导入方法依赖的package包/类
private static Statement applyAll(Statement result, Iterable<TestRule> rules,
Description description) {
for (TestRule each : rules) {
try {
result = each.apply(result, description);
} catch (Exception e) {
// Rules don't make errors, you silly
}
}
return result;
}
示例5: apply
import org.junit.rules.TestRule; //导入方法依赖的package包/类
/**
* @see TestRule#apply(org.junit.runners.model.Statement, org.junit.runner.
* Description)
*/
@Override
public Statement apply(final Statement base, final Description description) {
JptRuleChain.description = description;
Statement statement = base;
for (final TestRule testRule : this.ruleListStartingWithInnerMost) {
statement = testRule.apply(statement, description);
}
return statement;
}
示例6: apply
import org.junit.rules.TestRule; //导入方法依赖的package包/类
public Statement apply(Statement base, Description description) {
lookUpContainerSpecifics();
TestRule containerSpecificRule = containerSpecifics.getTestRule(description.getTestClass());
return containerSpecificRule.apply(base, description);
}