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

Method __init__

cover_agent/UnitTestGenerator.py:14–88  ·  view source on GitHub ↗

Initialize the UnitTestGenerator 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,
        agent_completion: AgentCompletionABC,
        test_command_dir: str = os.getcwd(),
        included_files: list = None,
        coverage_type="cobertura",
        additional_instructions: str = "",
        use_report_coverage_feature_flag: bool = False,
        project_root: str = "",
        logger: Optional[CustomLogger]=None,
        generate_log_files: bool=True,
    )

Source from the content-addressed store, hash-verified

12
13class UnitTestGenerator:
14 def __init__(
15 self,
16 source_file_path: str,
17 test_file_path: str,
18 code_coverage_report_path: str,
19 test_command: str,
20 llm_model: str,
21 agent_completion: AgentCompletionABC,
22 test_command_dir: str = os.getcwd(),
23 included_files: list = None,
24 coverage_type="cobertura",
25 additional_instructions: str = "",
26 use_report_coverage_feature_flag: bool = False,
27 project_root: str = "",
28 logger: Optional[CustomLogger]=None,
29 generate_log_files: bool=True,
30 ):
31 """
32 Initialize the UnitTestGenerator class with the provided parameters.
33
34 Parameters:
35 source_file_path (str): The path to the source file being tested.
36 test_file_path (str): The path to the test file where generated tests will be written.
37 code_coverage_report_path (str): The path to the code coverage report file.
38 test_command (str): The command to run tests.
39 llm_model (str): The language model to be used for test generation.
40 agent_completion (AgentCompletionABC): The agent completion object to be used for test generation.
41 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.
42 test_command_dir (str, optional): The directory where the test command should be executed. Defaults to the current working directory.
43 included_files (str, optional): Additional files to include (raw). Defaults to ""
44 coverage_type (str, optional): The type of coverage report. Defaults to "cobertura".
45 desired_coverage (int, optional): The desired coverage percentage. Defaults to 90.
46 additional_instructions (str, optional): Additional instructions for test generation. Defaults to an empty string.
47 use_report_coverage_feature_flag (bool, optional): Setting this to True considers the coverage of all the files in the coverage report.
48 This means we consider a test as good if it increases coverage for a different
49 file other than the source file. Defaults to False.
50 logger (CustomLogger, optional): The logger object for logging messages.
51 generate_log_files (bool): Whether or not to generate logs.
52
53 Returns:
54 None
55 """
56 # Class variables
57 self.project_root = project_root
58 self.source_file_path = source_file_path
59 self.test_file_path = test_file_path
60 self.code_coverage_report_path = code_coverage_report_path
61 self.test_command = test_command
62 self.test_command_dir = test_command_dir
63 self.included_files = included_files
64 self.coverage_type = coverage_type
65 self.additional_instructions = additional_instructions
66 self.language = self.get_code_language(source_file_path)
67 self.use_report_coverage_feature_flag = use_report_coverage_feature_flag
68 self.last_coverage_percentages = {}
69 self.llm_model = llm_model
70 self.agent_completion = agent_completion
71 self.generate_log_files = generate_log_files

Callers

nothing calls this directly

Calls 3

get_code_languageMethod · 0.95
FilePreprocessorClass · 0.90
get_loggerMethod · 0.80

Tested by

no test coverage detected