Package org.easetech.easytest.reports.data

Examples of org.easetech.easytest.reports.data.TestResultBean


                        if (runInContext) {
                            Repeat repeatTests = method.getAnnotation(Repeat.class);
                            if (repeatTests != null || getRepeatCount() != null) {
                                int repeatCount = getRepeatCount() != null ? getRepeatCount() : repeatTests.times();
                                for (int count = 0; count < repeatCount; count++) {
                                    TestResultBean testResultBean = new TestResultBean(methodWithData.getMethod()
                                        .getName(), new Date());
                                    testReportContainer.addTestResult(testResultBean);
                                    // Create a new FrameworkMethod for each set of test data
                                    EasyFrameworkMethod easyMethod = new EasyFrameworkMethod(method.getMethod(),
                                        testData, testResultBean, method.getName().concat(testData.toString()));
                                    easyMethod.setName(method.getName().concat("_").concat(String.valueOf(count))
                                        .concat(testData.toString()));
                                    if (isParent) {
                                        List<EasyFrameworkMethod> childMethods = new ArrayList<EasyFrameworkMethod>();
                                        easyMethod.setChildMethods(childMethods);
                                        finalList.add(easyMethod);
                                        isParent = false;
                                        parentMethod = easyMethod;
                                    } else {
                                        parentMethod.getChildMethods().add(easyMethod);
                                    }

                                }
                            } else {
                                TestResultBean testResultBean = new TestResultBean(
                                    methodWithData.getMethod().getName(), new Date());
                                testReportContainer.addTestResult(testResultBean);
                                // Create a new FrameworkMethod for each set of test data
                                EasyFrameworkMethod easyMethod = new EasyFrameworkMethod(method.getMethod(), testData,
                                    testResultBean, method.getName().concat(testData.toString()));
                                easyMethod.setName(method.getName().concat(testData.toString()));
                                // finalList.add(easyMethod);
                                if (isParent) {
                                    List<EasyFrameworkMethod> childMethods = new ArrayList<EasyFrameworkMethod>();
                                    easyMethod.setChildMethods(childMethods);
                                    isParent = false;
                                    finalList.add(easyMethod);
                                    parentMethod = easyMethod;
                                } else {
                                    parentMethod.getChildMethods().add(easyMethod);

                                    // finalList.add(easyMethod);
                                }
                            }
                        } else {
                            Repeat repeatTests = method.getAnnotation(Repeat.class);
                            if (repeatTests != null || getRepeatCount() != null) {
                                int repeatCount = getRepeatCount() != null ? getRepeatCount() : repeatTests.times();
                                for (int count = 0; count < repeatCount; count++) {
                                    TestResultBean testResultBean = new TestResultBean(methodWithData.getMethod()
                                        .getName(), new Date());
                                    testReportContainer.addTestResult(testResultBean);
                                    // Create a new FrameworkMethod for each set of test data
                                    EasyFrameworkMethod easyMethod = new EasyFrameworkMethod(method.getMethod(),
                                        testData, testResultBean, method.getName().concat(testData.toString()));
                                    easyMethod.setName(method.getName().concat("_").concat(String.valueOf(count))
                                        .concat(testData.toString()));
                                    finalList.add(easyMethod);
                                }
                            } else {
                                TestResultBean testResultBean = new TestResultBean(
                                    methodWithData.getMethod().getName(), new Date());
                                testReportContainer.addTestResult(testResultBean);
                                // Create a new FrameworkMethod for each set of test data
                                EasyFrameworkMethod easyMethod = new EasyFrameworkMethod(method.getMethod(), testData,
                                    testResultBean, method.getName().concat(testData.toString()));
View Full Code Here


            Repeat repeatTests = fMethod.getAnnotation(Repeat.class);
            if (repeatTests != null || getRepeatCount() != null) {
                int repeatCount = getRepeatCount() != null ? getRepeatCount() : repeatTests.times();
                for (int count = 0; count < repeatCount; count++) {
                    TestResultBean testResultBean = new TestResultBean(fMethod.getMethod().getName(), new Date());
                    testReportContainer.addTestResult(testResultBean);
                    // Create a new FrameworkMethod for each set of test data
                    EasyFrameworkMethod easyMethod = new EasyFrameworkMethod(fMethod.getMethod(), null, testResultBean,
                        fMethod.getName());
                    easyMethod.setName(fMethod.getName().concat("_").concat(String.valueOf(count)));
                    finalList.add(easyMethod);
                }
            } else {
                TestResultBean testResultBean = new TestResultBean(fMethod.getMethod().getName(), new Date());
                testReportContainer.addTestResult(testResultBean);
                EasyFrameworkMethod easyMethod = new EasyFrameworkMethod(fMethod.getMethod(), null, testResultBean,
                    fMethod.getName());
                finalList.add(easyMethod);
            }
View Full Code Here

        final TestRunDurationListener testRunDurationListener = new TestRunDurationListener();
        testRunNotifier.addListener(testRunDurationListener);
        final EachTestNotifier eachRunNotifier = new EachTestNotifier(testRunNotifier, null);
       
        String currentMethodName = method.getMethod().getName();
        TestResultBean testResult = method.getTestResult();
        Map<String, Object> writableRow = method.getTestData();
        Object returnObj = null;
        try {
            final Object[] values = complete.getMethodArguments(true);

            testResult.setInput(method.getTestData());
            // invoke test method
            eachRunNotifier.fireTestStarted();
            LOG.debug("Calling method {} with values {}", method.getName(), values);
            returnObj = method.invokeExplosively(freshInstance, values);
            eachRunNotifier.fireTestFinished();
           
            TestMethodDuration testItemDurationBean = new TestMethodDuration(currentMethodName,
                testRunDurationListener.getStartInNano(), testRunDurationListener.getEndInNano());
            testResult.addTestItemDurationBean(testItemDurationBean);
            testResult.setOutput((returnObj == null) ? "void" : returnObj);
            testResult.setPassed(Boolean.TRUE);
           
            if (writableRow != null) {
                if (returnObj != null) {
                    LOG.debug("Data returned by method {} is {} :", method.getName(), returnObj);
                    writableRow.put(Loader.ACTUAL_RESULT, returnObj);
                    Object expectedResult = writableRow.get(Loader.EXPECTED_RESULT);
                    // if expected result exist in user input test data,
                    // then compare that with actual output result
                    // and write the status back to writable map data.
                    if (expectedResult != null) {
                        LOG.debug("Expected result exists");
                        if (expectedResult.toString().equals(returnObj.toString())) {
                            writableRow.put(Loader.TEST_STATUS, Loader.TEST_PASSED);
                        } else {
                            writableRow.put(Loader.TEST_STATUS, Loader.TEST_FAILED);

                        }
                    }

                }
                LOG.debug("testItemDurationBean:" + testItemDurationBean);
                if (testItemDurationBean != null) {
                    Double testDuration = CommonUtils.getRounded(testItemDurationBean.getRoundedMsDifference()
                        .doubleValue(), 3);
                    LOG.debug("testItemDurationBean.getRoundedMsDifference():" + testDuration);
                    writableRow.put(Loader.DURATION, testDuration);
                }
            }
        } catch (AssumptionViolatedException e) {
            eachRunNotifier.addFailedAssumption(e);
            handleAssumptionViolation(e);
        } catch (Throwable e) {

            if (e instanceof AssertionError) { // Assertion error
                testResult.setPassed(Boolean.FALSE);
                testResult.setResult(e.getMessage());                      

            } else { // Exception
                testResult.setException(Boolean.TRUE);
                testResult.setExceptionResult(e.toString());

            }
            eachRunNotifier.addFailure(e);
            throw e;
        } finally {
View Full Code Here

    protected Statement withTestResult(final EasyFrameworkMethod method, final Statement statement) {
        return new Statement() {

            @Override
            public void evaluate() throws Throwable {
                TestResultBean testResult = method.getTestResult();
                try {
                    statement.evaluate();
                    testResult.setPassed(Boolean.TRUE);
                } catch (Throwable e) {

                    if (e instanceof AssertionError) { // Assertion error
                        testResult.setPassed(Boolean.FALSE);
                        testResult.setResult(e.getMessage());
                        throw e;

                    } else { // Exception
                        testResult.setException(Boolean.TRUE);
                        testResult.setExceptionResult(e.toString());
                        throw e;

                    }

                }
View Full Code Here

TOP

Related Classes of org.easetech.easytest.reports.data.TestResultBean

Copyright © 2018 www.massapicom. 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.