MCPcopy
hub / github.com/qodo-ai/qodo-cover / __init__

Method __init__

cover_agent/UnitTestValidator.py:22–131  ·  view source on GitHub ↗

Initialize the UnitTestValidator class with the provided parameters. Parameters: source_file_path (str): The path to the source file being tested. test_file_path (str): The path to the test file where generated tests will be written. code_coverag

(
        self,
        source_file_path: str,
        test_file_path: str,
        code_coverage_report_path: str,
        test_command: str,
        llm_model: str,
        max_run_time_sec: int,
        agent_completion: AgentCompletionABC,
        desired_coverage: int,
        comparison_branch: str,
        coverage_type: CoverageType,
        diff_coverage: bool,
        num_attempts: int,
        test_command_dir: str,
        additional_instructions: str,
        included_files: list,
        use_report_coverage_feature_flag: bool,
        project_root: str = "",
        logger: Optional[CustomLogger]=None,
        generate_log_files: bool=True,
    )

Source from the content-addressed store, hash-verified

20
21class UnitTestValidator:
22 def __init__(
23 self,
24 source_file_path: str,
25 test_file_path: str,
26 code_coverage_report_path: str,
27 test_command: str,
28 llm_model: str,
29 max_run_time_sec: int,
30 agent_completion: AgentCompletionABC,
31 desired_coverage: int,
32 comparison_branch: str,
33 coverage_type: CoverageType,
34 diff_coverage: bool,
35 num_attempts: int,
36 test_command_dir: str,
37 additional_instructions: str,
38 included_files: list,
39 use_report_coverage_feature_flag: bool,
40 project_root: str = "",
41 logger: Optional[CustomLogger]=None,
42 generate_log_files: bool=True,
43 ):
44 """
45 Initialize the UnitTestValidator class with the provided parameters.
46
47 Parameters:
48 source_file_path (str): The path to the source file being tested.
49 test_file_path (str): The path to the test file where generated tests will be written.
50 code_coverage_report_path (str): The path to the code coverage report file.
51 test_command (str): The command to run tests.
52 llm_model (str): The language model to be used for test generation.
53 max_run_time_sec (int): The maximum time in seconds to run the test command.
54 agent_completion (AgentCompletionABC): The agent completion object to use for test generation.
55 api_base (str, optional): The base API url to use in case model is set to Ollama or Hugging Face. Defaults to an empty string.
56 test_command_dir (str, optional): The directory where the test command should be executed. Defaults to the current working directory.
57 included_files (list, optional): A list of paths to included files. Defaults to None.
58 coverage_type (str, optional): The type of coverage report. Defaults to "cobertura".
59 desired_coverage (int, optional): The desired coverage percentage. Defaults to 90.
60 additional_instructions (str, optional): Additional instructions for test generation. Defaults to an empty string.
61 use_report_coverage_feature_flag (bool, optional): Setting this to True considers the coverage of all the files in the coverage report.
62 This means we consider a test as good if it increases coverage for a different
63 file other than the source file. Defaults to False.
64 logger (CustomLogger, optional): The logger object for logging messages.
65 generate_log_files (bool): Whether or not to generate logs.
66
67 Returns:
68 None
69 """
70 # Class variables
71 self.relevant_line_number_to_insert_imports_after = None
72 self.relevant_line_number_to_insert_tests_after = None
73 self.test_headers_indentation = None
74 self.project_root = project_root
75 self.source_file_path = source_file_path
76 self.test_file_path = test_file_path
77 self.code_coverage_report_path = code_coverage_report_path
78 self.test_command = test_command
79 self.test_command_dir = test_command_dir

Callers

nothing calls this directly

Calls 5

get_included_filesMethod · 0.95
get_code_languageMethod · 0.95
FilePreprocessorClass · 0.90
CoverageProcessorClass · 0.90
get_loggerMethod · 0.80

Tested by

no test coverage detected