Examples of JunitResult


Examples of jp.vmi.junit.result.JUnitResult

    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {
        ITestCase testCase = (ITestCase) invocation.getThis();
        Object[] args = invocation.getArguments();
        Context context = (Context) args[CONTEXT];
        JUnitResult jUnitResult;
        if (context instanceof JUnitResultHolder) {
            jUnitResult = ((JUnitResultHolder) context).getJUnitResult();
            jUnitResult.startTestCase((ITestSuite) args[PARENT], testCase);
        } else {
            jUnitResult = null;
        }
        StopWatch sw = testCase.getStopWatch();
        LogRecorder clr = new LogRecorder(context.getPrintStream());
        testCase.setLogRecorder(clr);
        sw.start();
        if (!testCase.isError()) {
            log.info("Start: {}", testCase);
            clr.info("Start: " + testCase);
        }
        if (testCase instanceof TestCase) {
            String baseURL = StringUtils.defaultString(context.getOverridingBaseURL(), ((TestCase) testCase).getBaseURL());
            log.info("baseURL: {}", baseURL);
            clr.info("baseURL: " + baseURL);
        }
        try {
            Result result = (Result) invocation.proceed();
            if (jUnitResult != null) {
                if (result.isSuccess())
                    jUnitResult.setSuccess(testCase);
                else
                    jUnitResult.setFailure(testCase, result.getMessage(), null);
            }
            return result;
        } catch (Throwable t) {
            String msg = t.getMessage();
            log.error(msg);
            clr.error(msg);
            if (jUnitResult != null)
                jUnitResult.setError(testCase, msg, t.toString());
            throw t;
        } finally {
            sw.end();
            if (!testCase.isError()) {
                String msg = "End(" + sw.getDurationString() + "): " + testCase;
                log.info(msg);
                clr.info(msg);
            }
            if (jUnitResult != null)
                jUnitResult.endTestCase(testCase);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.