Load test cases from JSON file. Args: file_path: Path to JSON file Returns: List of test case dictionaries Raises: FileNotFoundError: If file doesn't exist ValueError: If JSON is invalid
(self, file_path: str)
| 115 | pass |
| 116 | |
| 117 | def load_test_file(self, file_path: str) -> list[dict[str, Any]]: |
| 118 | """ |
| 119 | Load test cases from JSON file. |
| 120 | |
| 121 | Args: |
| 122 | file_path: Path to JSON file |
| 123 | |
| 124 | Returns: |
| 125 | List of test case dictionaries |
| 126 | |
| 127 | Raises: |
| 128 | FileNotFoundError: If file doesn't exist |
| 129 | ValueError: If JSON is invalid |
| 130 | """ |
| 131 | self.logger.info(f"Loading test cases from: {file_path}") |
| 132 | |
| 133 | try: |
| 134 | with open(file_path, encoding='utf-8') as f: |
| 135 | test_cases = json.load(f) |
| 136 | |
| 137 | if not isinstance(test_cases, list): |
| 138 | raise ValueError("JSON file must contain an array of test cases") |
| 139 | |
| 140 | # Filter test cases by type if test_type field exists |
| 141 | filtered_cases = [] |
| 142 | for case in test_cases: |
| 143 | if 'test_type' in case: |
| 144 | if case['test_type'] == self.test_type.value: |
| 145 | filtered_cases.append(case) |
| 146 | else: |
| 147 | # If no test_type field, include all cases (backward compatibility) |
| 148 | filtered_cases.append(case) |
| 149 | |
| 150 | self.logger.info(f"Loaded {len(filtered_cases)} test cases of type {self.test_type.value}") |
| 151 | return filtered_cases |
| 152 | |
| 153 | except FileNotFoundError as e: |
| 154 | raise FileNotFoundError(f"Test file not found: {file_path}") from e |
| 155 | except Exception as e: |
| 156 | raise ValueError(f"Error loading test file: {e}") from e |
| 157 | |
| 158 | async def run_tests(self, test_cases: list[dict[str, Any]]) -> dict[str, Any]: |
| 159 | """ |
no test coverage detected