コード例 #1
0
def get_tests_results(systest_build, os):
    tests_results = []
    test_build = Build(systest_build['name'], systest_build['number'])
    for test in test_build.test_data()['suites'][0]['cases']:
        test_result = TestResult(
            name=test['name'],
            group=expand_test_group(test['className'], systest_build['name'],
                                    os),
            status=test['status'].lower(),
            duration='{0}s'.format(int(test['duration']) + 1),
            url='{0}testReport/(root)/{1}/'.format(test_build.url,
                                                   test['name']),
            version='_'.join([test_build.build_data["id"]] + (
                test_build.build_data["description"] or test['name']).split()),
            description=test_build.build_data["description"] or test['name'],
        )
        tests_results.append(test_result)
    return tests_results
コード例 #2
0
ファイル: report.py プロジェクト: aglarendil/fuel-qa
def get_tests_results(systest_build):
    tests_results = []
    test_build = Build(systest_build['name'], systest_build['number'])
    for test in test_build.test_data()['suites'][0]['cases']:
        test_result = TestResult(
            name=test['name'],
            group=test['className'],
            status=test['status'].lower(),
            duration='{0}s'.format(int(test['duration']) + 1),
            url='{0}testReport/(root)/{1}/'.format(test_build.url,
                                                   test['name']),
            version='_'.join([test_build.build_data["id"]] +
                             (test_build.build_data["description"]
                              or test['name']).split()),
            description=test_build.build_data["description"] or
                test['name'],
        )
        tests_results.append(test_result)
    return tests_results
コード例 #3
0
def get_tests_results(systest_build, os):
    tests_results = []
    test_build = Build(systest_build['name'], systest_build['number'])
    run_test_data = test_build.test_data()
    test_classes = {}
    for one in run_test_data['suites'][0]['cases']:
        className = one['className']
        if className not in test_classes:
            test_classes[className] = {}
            test_classes[className]['child'] = []
            test_classes[className]['duration'] = 0
            test_classes[className]["failCount"] = 0
            test_classes[className]["passCount"] = 0
            test_classes[className]["skipCount"] = 0
        else:
            if one['className'] == one['name']:
                logger.warning("Found duplicate test in run - {}".format(
                    one['className']))
                continue

        test_class = test_classes[className]
        test_class['child'].append(one)
        test_class['duration'] += float(one['duration'])
        if one['status'].lower() in ('failed', 'error'):
            test_class["failCount"] += 1
        if one['status'].lower() == 'passed':
            test_class["passCount"] += 1
        if one['status'].lower() == 'skipped':
            test_class["skipCount"] += 1

    for klass in test_classes:
        klass_result = test_classes[klass]
        if len(klass_result['child']) == 1:
            test = klass_result['child'][0]
            if check_untested(test):
                continue
            check_blocked(test)
            test_result = TestResult(
                name=test['name'],
                group=expand_test_group(test['className'],
                                        systest_build['name'],
                                        os),
                status=test['status'].lower(),
                duration='{0}s'.format(int(test['duration']) + 1),
                url='{0}testReport/(root)/{1}/'.format(test_build.url,
                                                       test['name']),
                version='_'.join(
                    [test_build.build_data["id"]] + (
                        test_build.build_data["description"] or
                        test['name']).split()),
                description=test_build.build_data["description"] or
                    test['name'],
                comments=test['skippedMessage']
            )
        else:
            case_steps = []
            test_duration = sum(
                [float(c['duration']) for c in klass_result['child']])
            steps = [c for c in klass_result['child']
                     if c['name'].startswith('Step')]
            steps = sorted(steps, key=lambda k: k['name'])
            test_name = steps[0]['className']
            test_group = steps[0]['className']
            test_comments = None
            is_test_failed = any([s['status'].lower() in ('failed', 'error')
                                  for s in steps])

            for step in steps:
                if step['status'].lower() in ('failed', 'error'):
                    case_steps.append({
                        "content": step['name'],
                        "actual": step['errorStackTrace'] or
                        step['errorDetails'],
                        "status": step['status'].lower()})
                    test_comments = "{err}\n\n\n{stack}".format(
                        err=step['errorDetails'],
                        stack=step['errorStackTrace'])
                else:
                    case_steps.append({
                        "content": step['name'],
                        "actual": "pass",
                        "status": step['status'].lower()
                    })
            test_result = TestResult(
                name=test_name,
                group=expand_test_group(test_group,
                                        systest_build['name'],
                                        os),
                status='failed' if is_test_failed else 'passed',
                duration='{0}s'.format(int(test_duration) + 1),
                url='{0}testReport/(root)/{1}/'.format(test_build.url,
                                                       test_name),
                version='_'.join(
                    [test_build.build_data["id"]] + (
                        test_build.build_data["description"] or
                        test_name).split()),
                description=test_build.build_data["description"] or
                    test_name,
                comments=test_comments,
                steps=case_steps,
            )
        tests_results.append(test_result)
    return tests_results