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

org.test4j.integration.junit4.runner.SpringRunner Maven / Gradle / Ivy

package org.test4j.integration.junit4.runner;

import org.junit.runner.Runner;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.test4j.module.spring.SpringInit;

import java.lang.annotation.Annotation;
import java.util.List;

import static org.test4j.integration.junit4.helper.FrameworkParameterMethodHelper.computeTestParaMethods;
import static org.test4j.mock.faking.util.ReflectUtility.doThrow;

/**
 * SpringRunner
 *
 * @author wudarui
 */
@SuppressWarnings("rawtypes")
public class SpringRunner extends SpringJUnit4ClassRunner implements ProxyRunner {

    public SpringRunner(Class clazz) throws InitializationError {
        super(clazz);
    }

    protected Object createTest() throws Exception {
        Object target = super.createTest();
        SpringInit.doSpringInitial(target, this.getTestContextManager());
        return target;
    }

    @Override
    public List computeTestMethods() {
        Class testClass = this.getTestClass().getJavaClass();
        return computeTestParaMethods(testClass, super.computeTestMethods());
    }

    @Override
    public void validatePublicVoidNoArgMethods(Class annotation, boolean isStatic, List errors) {
        this.validateMethod(annotation, isStatic, errors);
    }

    public static Runner create(Class aClass) {
        try {
            return new SpringRunner(aClass);
        } catch (InitializationError e) {
            return doThrow(e);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy