All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jmockring.junit.TestSuppressionRule Maven / Gradle / Ivy

Go to download

jmockring - Java test MOCKing tool for spRING. A test harness tool for projects using the following technology stack: - Java 6+ - Spring 3.1 or greater as a DI/Deployment container - JUnit 4 and Mockito for testing - Jetty/Servlet API 3.0 for web app (war) deployment - for testing only Main features: 1) Partial Spring context deployment with automatic bean mocking for unavailable beans 2) Bootstrapping embedded Jetty server via JUnit runners 3) Configurable web application contexts 4) Automatic injection of Spring beans and mocks in JUnit tests via Java5 annotations

There is a newer version: 0.7.0
Show newest version
/*
 * Copyright (c) 2013 by Cisco Systems, Inc.
 * All rights reserved.
 */

package org.jmockring.junit;

import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author Pavel Lechev 
 * @since 07/08/13
 */
public class TestSuppressionRule implements TestRule {

    private static final Logger log = LoggerFactory.getLogger(TestSuppressionRule.class);

    private SuppressionEvaluator evaluator;

    public TestSuppressionRule(SuppressionEvaluator evaluator) {
        this.evaluator = evaluator;
    }

    @Override
    public Statement apply(Statement base, final Description description) {

        if (evaluator.isSuppressed()) {
            return new Statement() {
                @Override
                public void evaluate() throws Throwable {
                    description.addChild(Description.EMPTY);
                    log.info("LOG02060: Skipping test {}", description.getTestClass());
                }
            };
        }
        return base;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy