本文整理匯總了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);
}