def test_get_total_number_runnable(test_resource_dir):
    # Test: Pass file with No runnable tests; Expect return 0
    no_runnable = JasmineManifest([], [], [])
    assert no_runnable.get_total_number_runnable() == 0

    # Test: Pass file with runnable tests; Expect return > 0
    has_runnable = JasmineManifest([test_resource_dir + '*.ts'], [], [])
    assert has_runnable.get_total_number_runnable() > 0
Ejemplo n.º 2
0
def test_junit_manifest(report_path):
    setup_tests_abs_path = os.path.abspath(
        'pipeline/integration_tests/webdriver_tests/jasmine_reporter_test.ts')

    jasmine_manifest = JasmineManifest([setup_tests_abs_path],
                                       ['#integrationSuite'], ['#quarantine'])
    jasmine_manifest_skipped = JasmineManifest([setup_tests_abs_path],
                                               ['#quarantine'], [])
    report = JunitHelper(report_path)
    runnable_case_list = report.get_runnable_test_elements(jasmine_manifest)
    not_runnable_case_list = jasmine_manifest.get_all_non_runnable_tests()
    complete_case_list = jasmine_manifest.jasmine_tests
    total_junit_cases = len(report.get_test_attributes()
                            ) - 1  # one record is a fake for expired test
    total_tests = jasmine_manifest.get_total_number_tests()
    total_runnable = jasmine_manifest.get_total_number_runnable()
    total_not_runnable = jasmine_manifest.get_total_number_not_runnable()

    does_total_match = False
    for item in complete_case_list:
        print(item.test_name)
    if total_runnable + total_not_runnable == total_tests:
        does_total_match = True

    assert does_total_match
    assert total_tests == total_junit_cases
    assert jasmine_manifest.get_total_number_runnable(
    ) == jasmine_manifest_skipped.get_total_number_not_runnable()
    assert jasmine_manifest_skipped.get_total_number_runnable(
    ) == jasmine_manifest.get_total_number_not_runnable()
    assert jasmine_manifest.get_total_number_tests(
    ) == jasmine_manifest_skipped.get_total_number_tests()

    # runnable cases in junit are found within its own inventory
    for item in runnable_case_list:
        is_found = False
        for case in report.get_test_attributes():
            if case.is_match(item.get('name')):
                is_found = True
                break
        assert is_found