Run all test cases in the suite
(&self)
| 409 | |
| 410 | /// Run all test cases in the suite |
| 411 | pub fn run(&self) -> Result<TestSuiteResults, Box<dyn std::error::Error>> { |
| 412 | let start = std::time::Instant::now(); |
| 413 | let mut test_results = Vec::new(); |
| 414 | let mut passed = 0; |
| 415 | let mut failed = 0; |
| 416 | |
| 417 | // Create fixture and setup unique graph for this test suite |
| 418 | let fixture = TestFixture::new()?; |
| 419 | |
| 420 | match self.fixture_type { |
| 421 | FixtureType::Simple => { |
| 422 | fixture.setup_graph("test_suite_simple")?; |
| 423 | fixture.insert_simple_data()?; |
| 424 | } |
| 425 | FixtureType::Fraud => { |
| 426 | fixture.setup_graph("test_suite_fraud")?; |
| 427 | fixture.insert_fraud_data()?; |
| 428 | } |
| 429 | FixtureType::Empty => { |
| 430 | fixture.setup_graph("test_suite_empty")?; |
| 431 | } |
| 432 | }; |
| 433 | |
| 434 | // Run each test case |
| 435 | for test_case in &self.test_cases { |
| 436 | let test_start = std::time::Instant::now(); |
| 437 | |
| 438 | let result = fixture.query(&test_case.query); |
| 439 | |
| 440 | let (success, error) = match (&result, &test_case.expected_error) { |
| 441 | (Ok(query_result), None) => { |
| 442 | // Success expected, check row count if specified |
| 443 | if let Some(expected_rows) = test_case.expected_rows { |
| 444 | if query_result.rows.len() == expected_rows { |
| 445 | (true, None) |
| 446 | } else { |
| 447 | ( |
| 448 | false, |
| 449 | Some(format!( |
| 450 | "Expected {} rows, got {}", |
| 451 | expected_rows, |
| 452 | query_result.rows.len() |
| 453 | )), |
| 454 | ) |
| 455 | } |
| 456 | } else { |
| 457 | (true, None) |
| 458 | } |
| 459 | } |
| 460 | (Err(e), Some(expected_err)) => { |
| 461 | // Error expected, check if it matches |
| 462 | if e.contains(expected_err) { |
| 463 | (true, None) |
| 464 | } else { |
| 465 | ( |
| 466 | false, |
| 467 | Some(format!( |
| 468 | "Expected error containing '{}', got: {}", |
no test coverage detected