def create_test_suites(percent, project_id, current_project_path, list_of_bug_detecting_tests):
    result = {}
    modified_classes = utils.get_modified_classes(project_id, current_project_path)
    statement_coverage = utils.get_statement_coverage(project_id, current_project_path, modified_classes)
    checked_coverage = utils.get_checked_coverage(project_id, current_project_path, modified_classes)
    list_of_test_methods = get_relevant_test_methods(modified_classes, statement_coverage)
    statement_coverage_coverable_lines = utils.get_coverable_line_numbers(
        project_id, current_project_path, modified_classes, "statement_coverable_lines")
    checked_coverage_coverable_lines = utils.get_coverable_line_numbers(
        project_id, current_project_path, modified_classes, "checked_coverable_lines")

    # For each modified classes
    tmp_statement_result = create_test_suite(
       percent, list_of_test_methods, statement_coverage_coverable_lines, statement_coverage,
       list_of_bug_detecting_tests)
    tmp_checked_result = create_test_suite(
        percent, list_of_test_methods, checked_coverage_coverable_lines, checked_coverage,
        list_of_bug_detecting_tests)

    if len(tmp_checked_result.items()) > 0:
        result['checked_coverage'] = tmp_checked_result

    if len(tmp_statement_result.items()) > 0:
        result['statement_coverage'] = tmp_statement_result

    return result
Exemplo n.º 2
0
def for_each_project(project_name):
    project_range = project_config.get('projects', project_name).split(",")
    defects4j_project_path = project_config.get('paths',
                                                'defects4j_project_path')
    final_result = []
    # for each project fixed versions
    for project_id in range(int(project_range[0]), int(project_range[1]) + 1):
        is_project_path_exist = defects4j_project_path + "/" + project_name + "/trace_files/" + str(
            project_id) + "f"
        if path.isdir(is_project_path_exist):
            result = {}
            scores = {}
            patch_path = defects4j_project_path + "/" + project_name + "/" + "/patches/" + str(project_id) + \
                ".src.patch"
            current_project_path = defects4j_project_path + "/" + project_name
            modified_classes = utils.get_modified_classes(
                project_id, current_project_path)
            statement_coverage = utils.get_statement_coverage(
                project_id, current_project_path, modified_classes)
            checked_coverage = utils.get_checked_coverage(
                project_id, current_project_path, modified_classes)
            coverable_lines = utils.get_coverable_lines(
                project_id, current_project_path, modified_classes)
            dict_of_modified_coverable_lines = utils.get_modified_coverable_lines(
                patch_path, coverable_lines)
            list_of_bug_detecting_tests = utils.get_bug_detecting_tests(
                project_id, current_project_path)
            statement_covering_tests = get_covering_tests(
                statement_coverage, dict_of_modified_coverable_lines,
                'statement_coverable_lines')
            checked_covering_tests = get_covering_tests(
                checked_coverage, dict_of_modified_coverable_lines,
                'checked_coverable_lines')
            result['project_id'] = project_id
            scores['list_of_bug_detecting_tests'] = list_of_bug_detecting_tests
            scores['coverable_lines'] = dict_of_modified_coverable_lines
            scores['statement_covering_tests'] = statement_covering_tests
            scores['checked_covering_tests'] = checked_covering_tests
            result['scores'] = scores
            final_result.append(result)
    return final_result
Exemplo n.º 3
0
def for_each_project(project_name):
    project_range = project_config.get('projects', project_name).split(",")
    defects4j_project_path = project_config.get('paths',
                                                'defects4j_project_path')

    for project_id in range(int(project_range[0]), int(project_range[1]) + 1):
        print("running for {}, with bug-id {}".format(project_name,
                                                      project_id))
        is_project_path_exist = defects4j_project_path + "/" + project_name + "/trace_files/" + str(
            project_id) + "f"
        if path.isdir(is_project_path_exist):
            statement_as_rows = dict()
            checked_stmt_as_rows = dict()
            low_checked_coverage = 0
            # for i in range(0, int(test_suite_size)):
            exception_trace_path = defects4j_project_path + "/" + project_name + "/trigger_tests/" + str(
                project_id)
            patch_path = defects4j_project_path + "/" + project_name + "/" + "/patches/" + \
                         str(project_id) + ".src.patch"
            current_project_path = defects4j_project_path + "/" + project_name
            modified_classes = utils.get_modified_classes(
                project_id, current_project_path)
            coverable_lines = utils.get_coverable_lines(
                project_id, current_project_path, modified_classes)
            dict_of_modified_coverable_lines = dict()
            try:
                dict_of_modified_coverable_lines = utils.get_modified_coverable_lines(
                    patch_path, coverable_lines)
            except Exception:
                pass
            stmt_modified_coverable_lines = []
            checked_modified_coverable_lines = []
            current_project_path = defects4j_project_path + "/" + project_name
            list_of_bug_detecting_tests = utils.get_bug_detecting_tests(
                project_id, current_project_path)
            bug_detecting_test_natures = find_test_nature(
                exception_trace_path, list_of_bug_detecting_tests)
            modified_classes = utils.get_modified_classes(
                project_id, current_project_path)
            projects_statement_coverage = utils.get_statement_coverage(
                project_id, current_project_path, modified_classes)
            projects_checked_coverage = utils.get_checked_coverage(
                project_id, current_project_path, modified_classes)
            # print("list_of_bug_detecting_tests: " + ",".join(list_of_bug_detecting_tests))

            # take coverable lines
            for stmt in coverable_lines:
                try:
                    for stmt_line_no in coverable_lines[stmt][
                            'statement_coverable_lines']:
                        stmt_modified_coverable_lines.append(stmt + "." +
                                                             str(stmt_line_no))
                    for stmt_line_no in coverable_lines[stmt][
                            'checked_coverable_lines']:
                        checked_modified_coverable_lines.append(
                            stmt + "." + str(stmt_line_no))
                except TypeError:
                    pass

            for stmt_coverable_statements in stmt_modified_coverable_lines:
                statement_as_rows[stmt_coverable_statements] = []

            for checked_coverable_statements in checked_modified_coverable_lines:
                checked_stmt_as_rows[checked_coverable_statements] = []

            for stmt_covered_classes in projects_statement_coverage:
                for a_test in projects_statement_coverage[
                        stmt_covered_classes]:
                    for statements in projects_statement_coverage[
                            stmt_covered_classes][a_test]:
                        try:
                            statement_as_rows[stmt_covered_classes + "." +
                                              str(statements)].append(a_test)
                        except KeyError:
                            # print("bug detecting test does not cover this statement - statement coverage")
                            pass

            for checked_covered_classes in projects_checked_coverage:
                for a_test in projects_checked_coverage[
                        checked_covered_classes]:
                    for statements in projects_checked_coverage[
                            checked_covered_classes][a_test]:
                        try:
                            checked_stmt_as_rows[checked_covered_classes +
                                                 "." + str(statements)].append(
                                                     a_test)
                        except KeyError:
                            # print("bug detecting test does not cover this statement - checked coverage")
                            pass

            # print(dict_of_modified_coverable_lines)
            result_checked = {}
            # result_statement = {}

            # for statements in statement_as_rows:
            #     if statements in stmt_modified_coverable_lines:
            #         result_statement[statements] = divide(len(list_of_bug_detecting_tests),
            #                                               len(statement_as_rows[statements])) + ", " + \
            #                                        str(len(list_of_bug_detecting_tests)) + "/" + \
            #                                        str(len(statement_as_rows[statements]))

            for statements in checked_stmt_as_rows:
                if float(divide(len(a_intersection_b(list_of_bug_detecting_tests, checked_stmt_as_rows[statements])),
                                len(checked_stmt_as_rows[statements]))) > 0 and \
                        float(divide(len(a_intersection_b(list_of_bug_detecting_tests, statement_as_rows[statements])),
                                     len(statement_as_rows[statements]))) > 0:
                    result_checked[statements] = ".".join(statements.split(".")[:-1]) + \
                                                 ", {}-{}".format(project_name, project_id) + "," + \
                                                 divide(len(a_intersection_b(list_of_bug_detecting_tests,
                                                                             checked_stmt_as_rows[statements])),
                                                        len(checked_stmt_as_rows[statements])) + "," + \
                                                 divide(len(a_intersection_b(list_of_bug_detecting_tests,
                                                                             statement_as_rows[statements])),
                                                        len(statement_as_rows[statements])) + "," + \
                                                 str(len(a_intersection_b(list_of_bug_detecting_tests,
                                                                          checked_stmt_as_rows[statements]))) + "/" + \
                                                 str(len(checked_stmt_as_rows[statements])) + "," + \
                                                 str(len(a_intersection_b(list_of_bug_detecting_tests,
                                                                          statement_as_rows[statements]))) + "/" + \
                                                 str(len(statement_as_rows[statements])) + "," + \
                                                 determine_test_nature(bug_detecting_test_natures,
                                                                       a_intersection_b(
                                                                           list_of_bug_detecting_tests,
                                                                           checked_stmt_as_rows[statements])) + "," + \
                                                 determine_test_nature(bug_detecting_test_natures,
                                                                       a_intersection_b(
                                                                           list_of_bug_detecting_tests,
                                                                           statement_as_rows[statements])) + "," + \
                                                 is_this_statement_modified(dict_of_modified_coverable_lines,
                                                                            statements,
                                                                            "checked_coverable_lines") + "," + \
                                                 is_this_statement_modified(dict_of_modified_coverable_lines,
                                                                            statements,
                                                                            "statement_coverable_lines")

                    # print(".".join(statements.split(".")[:-1]) +
                    #       ", {}-{}".format(project_name, project_id) + ", " +
                    #       divide(len(a_intersection_b(list_of_bug_detecting_tests,
                    #                                   checked_stmt_as_rows[statements])),
                    #              len(checked_stmt_as_rows[statements])) + ", " +
                    #       divide(len(a_intersection_b(list_of_bug_detecting_tests,
                    #                                   statement_as_rows[statements])),
                    #              len(statement_as_rows[statements])) + ", " +
                    #       str(len(a_intersection_b(list_of_bug_detecting_tests,
                    #                                checked_stmt_as_rows[statements]))) + "/" +
                    #       str(len(checked_stmt_as_rows[statements])) + ", " +
                    #       str(len(a_intersection_b(list_of_bug_detecting_tests,
                    #                                statement_as_rows[statements]))) + "/" +
                    #       str(len(statement_as_rows[statements])) + "-> " +
                    #       "[" + ", ".join(statement_as_rows[statements]) + "] [" +
                    #       ", ".join(checked_stmt_as_rows[statements]) + "] [" +
                    #       ", ".join(list_of_bug_detecting_tests) + "]"
                    #       )
                    if statements in checked_modified_coverable_lines:
                        pass
                else:
                    low_checked_coverage = low_checked_coverage + 1

            # utils.write_list_as_csv([["target", "statement coverage probabilistic coupling",
            #                           "len(bug detecting tests)/len(covering tests)",
            #                           "checked coverage probabilistic coupling",
            #                           "len(bug detecting tests)/len(covering tests)"]],
            #                         "{}/prob_coupling_{}_{}_{}.csv"
            #                         .format(results_folder_path, "statement", project_name, project_id))
            # utils.write_dict_as_csv(result_statement, "{}/prob_coupling_{}_{}_{}.csv"
            #                         .format(results_folder_path, "statement", project_name, project_id))
            print("low_checked_coverage: " + str(low_checked_coverage))
            if len(result_checked) > 0:
                utils.write_list_as_csv([[
                    "target", "class_name", "Proj-id", "checked_pc",
                    "statement_pc",
                    "len(bug_detecting_tests)/len(covering_tests)",
                    "len(bug_detecting_tests)/len(covering_tests)",
                    "checked_nature", "statement_nature", "checked_modified",
                    "statement_modified"
                ]], "{}/prob_coupling_{}_{}.csv".format(
                    results_folder_path, project_name, project_id))

                utils.write_dict_as_csv(
                    result_checked, "{}/prob_coupling_{}_{}.csv".format(
                        results_folder_path, project_name, project_id))
Exemplo n.º 4
0
def for_each_project(project_name):
    project_range = project_config.get('projects', project_name).split(",")
    defects4j_project_path = project_config.get('paths',
                                                'defects4j_project_path')
    test_suite_size = project_config.get('projects', 'test_suite_size')

    for project_id in range(int(project_range[0]), int(project_range[1]) + 1):
        print("running for {}, with bug-id {}".format(project_name,
                                                      project_id))
        result = {}
        is_project_path_exist = defects4j_project_path + "/" + project_name + "/trace_files/" + str(
            project_id) + "f"
        probabilistic_coupling_statement_for_avg = []
        probabilistic_coupling_checked_for_avg = []
        adequacy_based_tests_statement = []
        adequacy_based_tests_checked = []
        list_of_bug_detecting_tests = []
        if path.isdir(is_project_path_exist):
            for i in range(0, int(test_suite_size)):
                current_project_path = defects4j_project_path + "/" + project_name
                list_of_bug_detecting_tests = utils.get_bug_detecting_tests(
                    project_id, current_project_path)

                modified_classes = utils.get_modified_classes(
                    project_id, current_project_path)
                projects_statement_coverage = utils.get_statement_coverage(
                    project_id, current_project_path, modified_classes)
                list_of_all_tests = get_relevant_test_methods(
                    modified_classes, projects_statement_coverage)

                statement_coverage_coverable_lines = utils.get_coverable_line_numbers(
                    project_id, current_project_path, modified_classes,
                    "statement_coverable_lines")
                checked_coverage_coverable_lines = utils.get_coverable_line_numbers(
                    project_id, current_project_path, modified_classes,
                    "checked_coverable_lines")

                projects_checked_coverage = utils.get_checked_coverage(
                    project_id, current_project_path, modified_classes)
                adequacy_based_tests_statement = generate_adequacy_based_tests(
                    statement_coverage_coverable_lines,
                    projects_statement_coverage, list_of_all_tests,
                    list_of_bug_detecting_tests)

                adequacy_based_tests_checked = generate_adequacy_based_tests(
                    checked_coverage_coverable_lines,
                    projects_checked_coverage, list_of_all_tests,
                    list_of_bug_detecting_tests)

                probabilistic_coupling_statement_for_avg.append(
                    get_proper_score(
                        a_intersection_b(
                            list_of_bug_detecting_tests,
                            adequacy_based_tests_statement[-1]['tests']) /
                        len(adequacy_based_tests_statement[-1]['tests'])))

                probabilistic_coupling_checked_for_avg.append(
                    get_proper_score(
                        a_intersection_b(
                            list_of_bug_detecting_tests,
                            adequacy_based_tests_checked[-1]['tests']) /
                        len(adequacy_based_tests_checked[-1]['tests'])))

        try:
            aggregated_csv.append([
                project_name + '-' + str(project_id),
                mean(probabilistic_coupling_statement_for_avg),
                mean(probabilistic_coupling_checked_for_avg)
            ])
        except statistics.StatisticsError:
            pass

        result['project_id'] = project_id
        result[
            'adequacy_based_tests_statement'] = adequacy_based_tests_statement
        result['adequacy_based_tests_checked'] = adequacy_based_tests_checked
        result['list_of_bug_detecting_tests'] = list_of_bug_detecting_tests
def for_each_project(project_name):
    project_range = project_config.get('projects', project_name).split(",")
    defects4j_project_path = project_config.get('paths',
                                                'defects4j_project_path')
    test_suite_size = project_config.get('projects', 'test_suite_size')

    for project_id in range(int(project_range[0]), int(project_range[1]) + 1):
        print("running for {}, with bug-id {}".format(project_name,
                                                      project_id))
        result = {}
        is_project_path_exist = defects4j_project_path + "/" + project_name + "/trace_files/" + str(
            project_id) + "f"
        probabilistic_coupling_statement_for_avg = []
        probabilistic_coupling_checked_for_avg = []
        adequacy_based_tests_statement = []
        adequacy_based_tests_checked = []
        list_of_bug_detecting_tests = []
        if path.isdir(is_project_path_exist):
            for i in range(0, int(test_suite_size)):
                patch_path = defects4j_project_path + "/" + project_name + "/" + "/patches/" + str(project_id) + \
                             ".src.patch"
                current_project_path = defects4j_project_path + "/" + project_name
                modified_classes = utils.get_modified_classes(
                    project_id, current_project_path)
                coverable_lines = utils.get_coverable_lines(
                    project_id, current_project_path, modified_classes)
                dict_of_modified_coverable_lines = utils.get_modified_coverable_lines(
                    patch_path, coverable_lines)
                stmt_modified_coverable_lines = []
                checked_modified_coverable_lines = []
                current_project_path = defects4j_project_path + "/" + project_name
                list_of_bug_detecting_tests = utils.get_bug_detecting_tests(
                    project_id, current_project_path)

                modified_classes = utils.get_modified_classes(
                    project_id, current_project_path)
                projects_statement_coverage = utils.get_statement_coverage(
                    project_id, current_project_path, modified_classes)
                list_of_all_tests = list(
                    dict.fromkeys(
                        get_relevant_test_methods(
                            modified_classes, projects_statement_coverage)))

                statement_coverage_coverable_lines = utils.get_coverable_line_numbers(
                    project_id, current_project_path, modified_classes,
                    "statement_coverable_lines")
                checked_coverage_coverable_lines = utils.get_coverable_line_numbers(
                    project_id, current_project_path, modified_classes,
                    "checked_coverable_lines")

                projects_checked_coverage = utils.get_checked_coverage(
                    project_id, current_project_path, modified_classes)
                adequacy_based_tests_statement = generate_adequacy_based_tests(
                    statement_coverage_coverable_lines,
                    projects_statement_coverage, list_of_all_tests,
                    list_of_bug_detecting_tests)

                adequacy_based_tests_checked = generate_adequacy_based_tests(
                    checked_coverage_coverable_lines,
                    projects_checked_coverage, list_of_all_tests,
                    list_of_bug_detecting_tests)

                print(" ")
                print_class_details()
                print("list_of_bug_detecting_tests: " +
                      ",".join(list_of_bug_detecting_tests))

                for stmt in dict_of_modified_coverable_lines:
                    for stmt_line_no in dict_of_modified_coverable_lines[stmt][
                            'statement_coverable_lines']:
                        stmt_modified_coverable_lines.append(stmt + "." +
                                                             str(stmt_line_no))
                    for stmt_line_no in dict_of_modified_coverable_lines[stmt][
                            'checked_coverable_lines']:
                        checked_modified_coverable_lines.append(
                            stmt + "." + str(stmt_line_no))

                projects_statement_coverage_adequacy = {}

                for stmt_covered_classes in projects_statement_coverage:
                    tmp_test_coverage = {}
                    for tests in projects_statement_coverage[
                            stmt_covered_classes]:
                        if tests in adequacy_based_tests_statement[-1][
                                'tests']:
                            tmp_test_coverage[
                                tests] = projects_statement_coverage[
                                    stmt_covered_classes][tests]
                    projects_statement_coverage_adequacy[
                        stmt_covered_classes] = tmp_test_coverage

                # print(projects_statement_coverage_adequacy)

                projects_checked_coverage_adequacy = {}
                # print(adequacy_based_tests_checked[-1]['tests'])

                for checked_covered_classes in projects_checked_coverage:
                    tmp_test_coverage = {}
                    for tests in projects_checked_coverage[
                            checked_covered_classes]:
                        if tests in adequacy_based_tests_checked[-1]['tests']:
                            tmp_test_coverage[
                                tests] = projects_checked_coverage[
                                    checked_covered_classes][tests]
                    projects_checked_coverage_adequacy[
                        checked_covered_classes] = tmp_test_coverage

                for stmt_covered_classes in projects_statement_coverage_adequacy:
                    for bug_detecting_test in list_of_bug_detecting_tests:
                        try:
                            for statements in projects_statement_coverage_adequacy[
                                    stmt_covered_classes][bug_detecting_test]:
                                statement_as_rows[stmt_covered_classes + "." +
                                                  str(statements)] = []
                        except KeyError:
                            pass

                for stmt_covered_classes in projects_statement_coverage_adequacy:
                    for a_test in projects_statement_coverage_adequacy[
                            stmt_covered_classes]:
                        for statements in projects_statement_coverage_adequacy[
                                stmt_covered_classes][a_test]:
                            try:
                                statement_as_rows[stmt_covered_classes + "." +
                                                  str(statements)].append(
                                                      a_test)
                            except KeyError:
                                # print("bug detecting test does not cover this statement - statement coverage")
                                pass

                for checked_covered_classes in projects_checked_coverage_adequacy:
                    for bug_detecting_test in list_of_bug_detecting_tests:
                        try:
                            for statements in projects_checked_coverage_adequacy[
                                    checked_covered_classes][
                                        bug_detecting_test]:
                                checked_stmt_as_rows[checked_covered_classes +
                                                     "." +
                                                     str(statements)] = []
                        except KeyError:
                            # print("Bug detecting test itself is not executed")
                            pass

                for checked_covered_classes in projects_checked_coverage_adequacy:
                    for a_test in projects_checked_coverage_adequacy[
                            checked_covered_classes]:
                        for statements in projects_checked_coverage_adequacy[
                                checked_covered_classes][a_test]:
                            try:
                                checked_stmt_as_rows[
                                    checked_covered_classes + "." +
                                    str(statements)].append(a_test)
                            except KeyError:
                                # print("bug detecting test does not cover this statement - checked coverage")
                                pass

                # print(dict_of_modified_coverable_lines)
                result_checked = {}
                result_statement = {}
                # for statements in statement_as_rows:
                #     if list_a_contains_b(statement_as_rows[statements], list_of_bug_detecting_tests):
                #         if statements in stmt_modified_coverable_lines:
                #             result_statement[statements] = str(len(statement_as_rows[statements])
                #                                                / len(adequacy_based_tests_statement)) + ", " + \
                #                                            str(len(statement_as_rows[statements])) + ", " + \
                #                                            str(len(adequacy_based_tests_statement))

                for statements in statement_as_rows:
                    if list_a_contains_b(statement_as_rows[statements],
                                         list_of_bug_detecting_tests):
                        if statements in stmt_modified_coverable_lines:
                            result_statement[statements] = "prob. coupling -> " + \
                                                           str(len(list_of_bug_detecting_tests) /
                                                               len(statement_as_rows[statements])) + ", " + \
                                                           "No. Of. test covers the stmt -> " + \
                                                           str(len(statement_as_rows[statements]))

                # for statements in checked_stmt_as_rows:
                #     if list_a_contains_b(checked_stmt_as_rows[statements], list_of_bug_detecting_tests):
                #         if statements in checked_modified_coverable_lines:
                #             result_checked[statements] = str(len(checked_stmt_as_rows[statements])
                #                                              / len(adequacy_based_tests_checked)) + ", " + \
                #                                            str(len(checked_stmt_as_rows[statements])) + ", " + \
                #                                            str(len(adequacy_based_tests_checked))

                for statements in checked_stmt_as_rows:
                    if list_a_contains_b(checked_stmt_as_rows[statements],
                                         list_of_bug_detecting_tests):
                        if statements in checked_modified_coverable_lines:
                            result_checked[statements] = "prob. coupling -> " + \
                                                         str(len(list_of_bug_detecting_tests) /
                                                             len(checked_stmt_as_rows[statements])) + ", " + \
                                                           "No. Of. test covers the stmt -> " + \
                                                         str(len(checked_stmt_as_rows[statements]))

                print("adequacy_based_tests_statement: " +
                      ", ".join(adequacy_based_tests_statement[-1]['tests']))
                print("projects_statement_coverage_adequacy: ")
                print(projects_statement_coverage_adequacy)
                for result in result_statement:
                    print(result + " -> " + str(result_statement[result]))
                print("\n---------------------------------------------\n")
                print("adequacy_based_tests_checked: " +
                      ", ".join(adequacy_based_tests_checked[-1]['tests']))
                print("projects_checked_coverage_adequacy: ")
                print(projects_checked_coverage_adequacy)
                for result in result_checked:
                    print(result + " -> " + str(result_checked[result]))

                exit(0)

                probabilistic_coupling_statement_for_avg.append(
                    get_proper_score(
                        a_intersection_b(
                            list_of_bug_detecting_tests,
                            adequacy_based_tests_statement[-1]['tests']) /
                        len(adequacy_based_tests_statement[-1]['tests'])))

                probabilistic_coupling_checked_for_avg.append(
                    get_proper_score(
                        a_intersection_b(
                            list_of_bug_detecting_tests,
                            adequacy_based_tests_checked[-1]['tests']) /
                        len(adequacy_based_tests_checked[-1]['tests'])))

        try:
            aggregated_csv.append([
                project_name + '-' + str(project_id),
                mean(probabilistic_coupling_statement_for_avg),
                mean(probabilistic_coupling_checked_for_avg)
            ])
        except statistics.StatisticsError:
            pass

        result['project_id'] = project_id
        result[
            'adequacy_based_tests_statement'] = adequacy_based_tests_statement
        result['adequacy_based_tests_checked'] = adequacy_based_tests_checked
        result['list_of_bug_detecting_tests'] = list_of_bug_detecting_tests
def for_each_project(project_name):
    project_range = project_config.get('projects', project_name).split(",")
    defects4j_project_path = project_config.get('paths',
                                                'defects4j_project_path')
    test_suite_size = project_config.get('projects', 'test_suite_size')

    for project_id in range(int(project_range[0]), int(project_range[1]) + 1):
        print("running for {}, with bug-id {}".format(project_name,
                                                      project_id))
        result = {}
        is_project_path_exist = defects4j_project_path + "/" + project_name + "/trace_files/" + str(
            project_id) + "f"
        probabilistic_coupling_statement_for_avg = []
        probabilistic_coupling_checked_for_avg = []
        adequacy_based_tests_statement = []
        adequacy_based_tests_checked = []
        list_of_bug_detecting_tests = []
        if path.isdir(is_project_path_exist):
            for i in range(0, int(test_suite_size)):
                current_project_path = defects4j_project_path + "/" + project_name
                list_of_bug_detecting_tests = utils.get_bug_detecting_tests(
                    project_id, current_project_path)

                modified_classes = utils.get_modified_classes(
                    project_id, current_project_path)
                projects_statement_coverage = utils.get_statement_coverage(
                    project_id, current_project_path, modified_classes)

                list_of_all_tests = get_relevant_test_methods(
                    modified_classes, projects_statement_coverage)
                list_of_all_tests = list(dict.fromkeys(list_of_all_tests))
                for stmt_covered_classes in projects_statement_coverage:
                    for bug_detecting_test in list_of_bug_detecting_tests:
                        for statements in projects_statement_coverage[
                                stmt_covered_classes][bug_detecting_test]:
                            statement_as_rows.append(stmt_covered_classes +
                                                     "." + str(statements))

                projects_checked_coverage = utils.get_checked_coverage(
                    project_id, current_project_path, modified_classes)
                statement_template = pd.DataFrame(index=statement_as_rows,
                                                  columns=list_of_all_tests)

                for checked_covered_classes in projects_checked_coverage:
                    for bug_detecting_test in list_of_bug_detecting_tests:
                        try:
                            for statements in projects_checked_coverage[
                                    checked_covered_classes][
                                        bug_detecting_test]:
                                checked_stmt_as_rows.append(
                                    checked_covered_classes + "." +
                                    str(statements))
                        except KeyError:
                            print(
                                "Bug detecting test does not covered this class"
                            )

                checked_template = pd.DataFrame(index=checked_stmt_as_rows,
                                                columns=list_of_all_tests)

                # print(statement_template)

                for stmt_covered_classes in projects_statement_coverage:
                    for a_test in list_of_all_tests:
                        try:
                            for statements in projects_statement_coverage[
                                    stmt_covered_classes][a_test]:
                                statement_template[a_test][stmt_covered_classes
                                                           + "." +
                                                           str(statements)] = 1
                        except KeyError:
                            pass

                statement_template.to_csv('statement_template.csv')

                for checked_covered_classes in projects_statement_coverage:
                    for a_test in list_of_all_tests:
                        try:
                            for statements in projects_statement_coverage[
                                    checked_covered_classes][a_test]:
                                checked_template[a_test][
                                    checked_covered_classes + "." +
                                    str(statements)] = 1
                        except KeyError:
                            pass
                checked_template.to_csv('checked_template.csv')

                # for index, row in statement_template.iterrows():
                #     print(row)
                print(statement_template.
                      loc['com.fasterxml.jackson.databind.JavaType.76'])

                exit(0)

                statement_coverage_coverable_lines = utils.get_coverable_line_numbers(
                    project_id, current_project_path, modified_classes,
                    "statement_coverable_lines")
                checked_coverage_coverable_lines = utils.get_coverable_line_numbers(
                    project_id, current_project_path, modified_classes,
                    "checked_coverable_lines")

                projects_checked_coverage = utils.get_checked_coverage(
                    project_id, current_project_path, modified_classes)
                adequacy_based_tests_statement = generate_adequacy_based_tests(
                    statement_coverage_coverable_lines,
                    projects_statement_coverage, list_of_all_tests,
                    list_of_bug_detecting_tests)

                adequacy_based_tests_checked = generate_adequacy_based_tests(
                    checked_coverage_coverable_lines,
                    projects_checked_coverage, list_of_all_tests,
                    list_of_bug_detecting_tests)

                probabilistic_coupling_statement_for_avg.append(
                    get_proper_score(
                        a_intersection_b(
                            list_of_bug_detecting_tests,
                            adequacy_based_tests_statement[-1]['tests']) /
                        len(adequacy_based_tests_statement[-1]['tests'])))

                probabilistic_coupling_checked_for_avg.append(
                    get_proper_score(
                        a_intersection_b(
                            list_of_bug_detecting_tests,
                            adequacy_based_tests_checked[-1]['tests']) /
                        len(adequacy_based_tests_checked[-1]['tests'])))

        try:
            aggregated_csv.append([
                project_name + '-' + str(project_id),
                mean(probabilistic_coupling_statement_for_avg),
                mean(probabilistic_coupling_checked_for_avg)
            ])
        except statistics.StatisticsError:
            pass

        result['project_id'] = project_id
        result[
            'adequacy_based_tests_statement'] = adequacy_based_tests_statement
        result['adequacy_based_tests_checked'] = adequacy_based_tests_checked
        result['list_of_bug_detecting_tests'] = list_of_bug_detecting_tests