Java 类org.springframework.boot.groovy.DelegateTestRunner 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:TestRunner.java   
@Override
public void run() {
    try {
        if (this.testClasses.length == 0) {
            System.out.println("No tests found");
        }
        else {
            ClassLoader contextClassLoader = Thread.currentThread()
                    .getContextClassLoader();
            Class<?> delegateClass = contextClassLoader
                    .loadClass(DelegateTestRunner.class.getName());
            Class<?> resultClass = contextClassLoader
                    .loadClass("org.junit.runner.Result");
            Method runMethod = delegateClass.getMethod("run", Class[].class,
                    resultClass);
            Object result = resultClass.newInstance();
            runMethod.invoke(null, this.testClasses, result);
            boolean wasSuccessful = (Boolean) resultClass
                    .getMethod("wasSuccessful").invoke(result);
            if (!wasSuccessful) {
                throw new RuntimeException("Tests Failed.");
            }
        }
    }
    catch (Exception ex) {
        ReflectionUtils.rethrowRuntimeException(ex);
    }
}
项目:spring-boot-concourse    文件:TestRunner.java   
@Override
public void run() {
    try {
        if (this.testClasses.length == 0) {
            System.out.println("No tests found");
        }
        else {
            ClassLoader contextClassLoader = Thread.currentThread()
                    .getContextClassLoader();
            Class<?> delegateClass = contextClassLoader
                    .loadClass(DelegateTestRunner.class.getName());
            Class<?> resultClass = contextClassLoader
                    .loadClass("org.junit.runner.Result");
            Method runMethod = delegateClass.getMethod("run", Class[].class,
                    resultClass);
            Object result = resultClass.newInstance();
            runMethod.invoke(null, this.testClasses, result);
            boolean wasSuccessful = (Boolean) resultClass
                    .getMethod("wasSuccessful").invoke(result);
            if (!wasSuccessful) {
                throw new RuntimeException("Tests Failed.");
            }
        }
    }
    catch (Exception ex) {
        ReflectionUtils.rethrowRuntimeException(ex);
    }
}
项目:contestparser    文件:TestRunner.java   
@Override
public void run() {
    try {
        if (this.testClasses.length == 0) {
            System.out.println("No tests found");
        }
        else {
            ClassLoader contextClassLoader = Thread.currentThread()
                    .getContextClassLoader();
            Class<?> delegateClass = contextClassLoader
                    .loadClass(DelegateTestRunner.class.getName());
            Class<?> resultClass = contextClassLoader
                    .loadClass("org.junit.runner.Result");
            Method runMethod = delegateClass.getMethod("run", Class[].class,
                    resultClass);
            Object result = resultClass.newInstance();
            runMethod.invoke(null, this.testClasses, result);
            boolean wasSuccessful = (Boolean) resultClass
                    .getMethod("wasSuccessful").invoke(result);
            if (!wasSuccessful) {
                throw new RuntimeException("Tests Failed.");
            }
        }
    }
    catch (Exception ex) {
        ReflectionUtils.rethrowRuntimeException(ex);
    }
}