MCPcopy Create free account
hub / github.com/nlweb-ai/NLWeb / run_tests

Method run_tests

AskAgent/python/testing/base_test_runner.py:158–223  ·  view source on GitHub ↗

Run multiple test cases and return summary. Args: test_cases: List of test case dictionaries Returns: Dictionary with test summary and results

(self, test_cases: list[dict[str, Any]])

Source from the content-addressed store, hash-verified

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 """
160 Run multiple test cases and return summary.
161
162 Args:
163 test_cases: List of test case dictionaries
164
165 Returns:
166 Dictionary with test summary and results
167 """
168 results = []
169 passed = 0
170 failed = 0
171
172 self.logger.info(f"Running {len(test_cases)} tests of type {self.test_type.value}")
173
174 for idx, test_case in enumerate(test_cases, 1):
175 # Validate test case
176 is_valid, error_msg = self.validate_test_case(test_case)
177
178 if not is_valid:
179 self.logger.error(f"Invalid test case {idx}: {error_msg}")
180 result = TestResult(
181 test_case=TestCase(
182 test_type=self.test_type,
183 test_id=idx,
184 original_case_num=test_case.get('original_case_num', idx)
185 ),
186 success=False,
187 error=f"Validation error: {error_msg}"
188 )
189 failed += 1
190 else:
191 # Run the test
192 try:
193 result = await self.run_single_test(test_case)
194 if result.success:
195 passed += 1
196 else:
197 failed += 1
198 except Exception as e:
199 self.logger.exception(f"Error running test {idx}: {e}")
200 result = TestResult(
201 test_case=TestCase(
202 test_type=self.test_type,
203 test_id=idx,
204 original_case_num=test_case.get('original_case_num', idx)
205 ),
206 success=False,
207 error=str(e)
208 )
209 failed += 1
210
211 results.append(result)
212
213 # Generate summary
214 summary = {
215 'test_type': self.test_type.value,

Callers 4

mainFunction · 0.80
run_test_fileMethod · 0.80
mainFunction · 0.80
mainFunction · 0.80

Calls 9

validate_test_caseMethod · 0.95
run_single_testMethod · 0.95
TestResultClass · 0.85
TestCaseClass · 0.85
getMethod · 0.80
infoMethod · 0.45
errorMethod · 0.45
exceptionMethod · 0.45
to_dictMethod · 0.45

Tested by

no test coverage detected