当前位置: 首页>>代码示例>>Java>>正文


Java MethodRule类代码示例

本文整理汇总了Java中org.junit.rules.MethodRule的典型用法代码示例。如果您正苦于以下问题:Java MethodRule类的具体用法?Java MethodRule怎么用?Java MethodRule使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MethodRule类属于org.junit.rules包,在下文中一共展示了MethodRule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applyRuleToLastStatement

import org.junit.rules.MethodRule; //导入依赖的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;
}
 
开发者ID:awenblue,项目名称:powermock,代码行数:17,代码来源:PowerMockJUnit49RunnerDelegateImpl.java

示例2: apply

import org.junit.rules.MethodRule; //导入依赖的package包/类
@Override
public Statement apply(final Statement result, final FrameworkMethod method, final Object target) {
    Statement lastResult = result;

    for (final MethodRule rule : getRules()) {
        lastResult = rule.apply(lastResult, method, target);
    }

    return lastResult;
}
 
开发者ID:dadrus,项目名称:jpa-unit,代码行数:11,代码来源:JpaUnitRule.java

示例3: withRules

import org.junit.rules.MethodRule; //导入依赖的package包/类
private Statement withRules( FrameworkMethod method, Object target, Statement statement )
{
        Statement result = statement;
        for( MethodRule each : rules( target ) )
                result = each.apply( result, method, target );
        return result;
}
 
开发者ID:JoeBeeton,项目名称:FuzzUnit,代码行数:8,代码来源:FuzzUnitTestRunner.java

示例4: rules

import org.junit.rules.MethodRule; //导入依赖的package包/类
/**
 * @param test the test class
 * @return the MethodRules that can transform the block
 *         that runs each method in the tested class.
 */
protected List<MethodRule> rules( Object test )
{
        List<MethodRule> results = new ArrayList<MethodRule>();
        for( FrameworkField each : ruleFields() )
                results.add( createRule( test, each ) );
        return results;
}
 
开发者ID:JoeBeeton,项目名称:FuzzUnit,代码行数:13,代码来源:FuzzUnitTestRunner.java

示例5: createRule

import org.junit.rules.MethodRule; //导入依赖的package包/类
private MethodRule createRule( Object test, FrameworkField each )
{
        try {
                return (MethodRule) each.get( test );
        } catch( IllegalAccessException e ) {
                throw new RuntimeException( "How did getFields return a field we couldn't access?" );
        } catch( IllegalArgumentException ex ) {
                throw new RuntimeException( "How did getFields return a field we couldn't access?" );
        }
}
 
开发者ID:JoeBeeton,项目名称:FuzzUnit,代码行数:11,代码来源:FuzzUnitTestRunner.java

示例6: getTemporaryFolder

import org.junit.rules.MethodRule; //导入依赖的package包/类
@Rule
public MethodRule getTemporaryFolder() {
    return new MethodRule() {
        public Statement apply(Statement base, FrameworkMethod method,
                Object target) {
            return null;
        }
    };
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:10,代码来源:RuleFieldValidatorTest.java

示例7: rules

import org.junit.rules.MethodRule; //导入依赖的package包/类
@Override
protected List<MethodRule> rules(Object test) {
    final LinkedList<MethodRule> methodRules = new LinkedList<MethodRule>(
            super.rules(test));
    methodRules.add(new FlipBitRule());
    return methodRules;
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:8,代码来源:BlockJUnit4ClassRunnerOverrideTest.java

示例8: withRules

import org.junit.rules.MethodRule; //导入依赖的package包/类
/**
    * method taken as is from BlockJUnit4ClassRunner 4.7 in order to preserve
    * its functionality over following versions
    */
   private Statement withRules(FrameworkMethod method, Object target,
    Statement statement) {
Statement result = statement;
for (MethodRule each : rules(target)) {
    result = each.apply(result, method, target);
}
return result;
   }
 
开发者ID:lucaspouzac,项目名称:contiperf,代码行数:13,代码来源:BlockContiPerfClassRunner.java

示例9: createRule

import org.junit.rules.MethodRule; //导入依赖的package包/类
/**
    * method taken as is from BlockJUnit4ClassRunner 4.7 in order to preserve
    * its functionality over following versions
    */
   private MethodRule createRule(Object test, FrameworkField each) {
try {
    return (MethodRule) each.get(test);
} catch (IllegalAccessException e) {
    throw new RuntimeException(
	    "How did getFields return a field we couldn't access?");
}
   }
 
开发者ID:lucaspouzac,项目名称:contiperf,代码行数:13,代码来源:BlockContiPerfClassRunner.java

示例10: apply

import org.junit.rules.MethodRule; //导入依赖的package包/类
/**
 * {@inheritDoc} Before evaluation of the base statement, the test instance
 * will initialized.
 */
@Override
public Statement apply(final Statement base, final FrameworkMethod method, final Object target) {
    Statement appliedStatement = base;
    for (MethodRule rule : methodRuleChain) {
        appliedStatement = rule.apply(appliedStatement, method, target);
    }

    return statement(appliedStatement, target);

}
 
开发者ID:needle4j,项目名称:needle4j,代码行数:15,代码来源:NeedleRule.java

示例11: withOuter

import org.junit.rules.MethodRule; //导入依赖的package包/类
/**
 * Encloses the added rule.
 * 
 * @param rule
 *            - outer method rule
 * @return {@link NeedleRule}
 */
public NeedleRule withOuter(final MethodRule rule) {
    if (rule instanceof InjectionProvider) {
        addInjectionProvider((InjectionProvider<?>) rule);
    }
    methodRuleChain.add(0, rule);
    return this;
}
 
开发者ID:needle4j,项目名称:needle4j,代码行数:15,代码来源:NeedleRule.java

示例12: build

import org.junit.rules.MethodRule; //导入依赖的package包/类
@Override
protected NeedleRule build(final InjectionConfiguration injectionConfiguration,
        final InjectionProvider<?>... injectionProvider) {
    final NeedleRule needleRule = new NeedleRule(injectionConfiguration, injectionProvider);

    for (final MethodRule rule : methodRuleChain) {
        needleRule.withOuter(rule);
    }
    return needleRule;
}
 
开发者ID:needle4j,项目名称:needle4j,代码行数:11,代码来源:NeedleRuleBuilder.java

示例13: rules

import org.junit.rules.MethodRule; //导入依赖的package包/类
/**
 * Internal JUnit method - overridden to add a {@link MoxieRule} to all tests.
 */
@Override
protected List<MethodRule> rules(Object test) {
    ArrayList<MethodRule> result = new ArrayList<MethodRule>(super.rules(test));
    result.add(new MoxieRule());
    return result;
}
 
开发者ID:pobrelkey,项目名称:moxiemocks,代码行数:10,代码来源:MoxieRunner.java

示例14: contains

import org.junit.rules.MethodRule; //导入依赖的package包/类
public boolean contains(MethodRule methodRule) {
    for (TestRuleInTestHierarchy t : testRulePositionInTestHierarchies) {
        if (t.getTestRule().equals(methodRule))
            return true;
    }
    return false;
}
 
开发者ID:bechte,项目名称:junit-hierarchicalcontextrunner,代码行数:8,代码来源:TestRuleDefinitions.java

示例15: getMethodRulesDefinedForThisHierarchyLevel

import org.junit.rules.MethodRule; //导入依赖的package包/类
public List<MethodRule> getMethodRulesDefinedForThisHierarchyLevel(Object hierarchyContext) {
    List<MethodRule> result = new ArrayList<MethodRule>();
    for (MethodRuleInTestHierarchy testRulePosition : methodRulePositionInTestHierarchies)
        if (hierarchyOfTestsFromLowestToHighest.indexOf(testRulePosition.getObjectRepresentingHierarchyLevel()) >= hierarchyOfTestsFromLowestToHighest.indexOf(hierarchyContext))
            result.add(testRulePosition.getMethodRule());
    return result;
}
 
开发者ID:bechte,项目名称:junit-hierarchicalcontextrunner,代码行数:8,代码来源:TestRuleDefinitions.java


注:本文中的org.junit.rules.MethodRule类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。