Decouple assertion evaluation from runner - #280
Conversation
…tions Add three integration tests in processor/executor_tests.rs per PRD-3 testing decisions: - test_processor_evaluates_assertions_on_raw_executor_result: executor returns raw HttpResult with empty assertion_results; processor evaluates assertions from the request and populates them. - test_processor_evaluates_assertions_and_marks_failure: executor returns 404 but request expects status 200; processor marks result as failed. - test_processor_without_assertions_does_not_evaluate: no assertions on request; processor leaves assertion_results empty. All tests pass with the current processor-layer assertion evaluation.
Temporarily remove assertion evaluation from process_single_request and process_requests_incremental. This is the RED phase of TDD: - Without assertion evaluation in the processor, the integration tests test_processor_evaluates_assertions_on_raw_executor_result and test_processor_evaluates_assertions_and_marks_failure now fail. The runner was already decoupled (returns Vec::new() for assertion_results). This commit completes the separation: assertion evaluation will be re-added to the processor layer only, verifying the tests catch the missing behavior.
GREEN phase of TDD: re-add assertion evaluation to process_single_request and process_requests_incremental. The processor now: 1. After receiving the HttpResult from the executor, checks if the request has assertions. 2. Calls assertions::evaluate_assertions to evaluate them against the result. 3. Sets result.success to the AND of all assertion results. 4. Sets result.assertion_results to the evaluated Vec<AssertionResult>. This completes the decoupling: the runner returns raw HttpResult with empty assertion_results, and the processor handles assertion evaluation. The integration tests test_processor_evaluates_assertions_on_raw_executor_result and test_processor_evaluates_assertions_and_marks_failure now pass.
…ntal path Add test_incremental_evaluates_assertions_on_raw_executor_result and test_incremental_evaluates_assertions_and_marks_failure to verify that the incremental processing path (process_requests_incremental) evaluates assertions when the executor returns raw results with empty assertion_results. This ensures both the sync processor path (process_single_request) and the async-ready incremental path (process_requests_incremental) correctly evaluate assertions, completing the assertion decoupling coverage.
📝 WalkthroughWalkthroughAdds five unit tests across ChangesProcessor Assertion Evaluation Tests
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #280 +/- ##
==========================================
- Coverage 92.56% 92.53% -0.04%
==========================================
Files 68 68
Lines 8663 8663
==========================================
- Hits 8019 8016 -3
- Misses 644 647 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/core/src/processor/executor_tests.rs (1)
2108-2113: ⚡ Quick winStrengthen these tests to prove
successis recomputed, not preserved.Both tests currently seed
HttpResult.successwith the expected final value, which can mask regressions. Seed the opposite value and assert the processor flips it based on assertion outcomes.Suggested test hardening
@@ fn test_processor_evaluates_assertions_on_raw_executor_result() { - let mock = MockHttpExecutor::new(vec![HttpResult { + let mock = MockHttpExecutor::new(vec![HttpResult { request_name: None, status_code: 200, - success: true, + success: false, // should be overwritten to true by assertion evaluation error_message: None, @@ assert_eq!(http_result.assertion_results.len(), 1); + assert!(http_result.success, "processor should set success=true when assertions pass"); @@ fn test_processor_evaluates_assertions_and_marks_failure() { let mock = MockHttpExecutor::new(vec![HttpResult { request_name: None, status_code: 404, - success: false, + success: true, // should be overwritten to false by assertion evaluation error_message: None,Also applies to: 2131-2133, 2167-2171, 2196-2199
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/core/src/processor/executor_tests.rs` around lines 2108 - 2113, The tests are seeding HttpResult.success with the expected final value, which prevents them from catching regressions where success is not being recomputed. In all MockHttpExecutor instantiations (at the locations spanning 2108-2113, 2131-2133, 2167-2171, and 2196-2199), change the success field to have the opposite boolean value from what the test expects to verify, then ensure the subsequent assertions confirm the processor correctly recomputes and flips the success value based on the assertion outcomes rather than preserving the initial mock value.src/core/src/processor/incremental_tests.rs (1)
461-465: ⚡ Quick winApply the same
success-recompute hardening in incremental tests.These tests also pre-seed
successto expected outcomes. Invert the initial values so the test verifies processor recomputation rather than passthrough behavior.Suggested test hardening
@@ fn test_incremental_evaluates_assertions_on_raw_executor_result() { let raw_result = HttpResult { request_name: None, status_code: 200, - success: true, + success: false, // should be recomputed to true error_message: None, @@ assert_eq!(http_result.assertion_results.len(), 1); + assert!(http_result.success, "processor should set success=true when assertions pass"); @@ fn test_incremental_evaluates_assertions_and_marks_failure() { let raw_result = HttpResult { request_name: None, status_code: 404, - success: false, + success: true, // should be recomputed to false error_message: None,Also applies to: 490-498, 522-526, 551-554
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/core/src/processor/incremental_tests.rs` around lines 461 - 465, The test cases in the incremental_tests.rs file are pre-seeding the success field with expected outcomes, which means they are not actually verifying that the processor recomputes this field. To properly harden these tests, invert the initial boolean value of the success field in all HttpResult initializations throughout the test cases (at lines around 461-465, 490-498, 522-526, and 551-554). Change true to false and false to true so that the tests verify the processor correctly recomputes the success field to reach the expected outcome, rather than just passing through the pre-seeded value.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/core/src/processor/executor_tests.rs`:
- Around line 2108-2113: The tests are seeding HttpResult.success with the
expected final value, which prevents them from catching regressions where
success is not being recomputed. In all MockHttpExecutor instantiations (at the
locations spanning 2108-2113, 2131-2133, 2167-2171, and 2196-2199), change the
success field to have the opposite boolean value from what the test expects to
verify, then ensure the subsequent assertions confirm the processor correctly
recomputes and flips the success value based on the assertion outcomes rather
than preserving the initial mock value.
In `@src/core/src/processor/incremental_tests.rs`:
- Around line 461-465: The test cases in the incremental_tests.rs file are
pre-seeding the success field with expected outcomes, which means they are not
actually verifying that the processor recomputes this field. To properly harden
these tests, invert the initial boolean value of the success field in all
HttpResult initializations throughout the test cases (at lines around 461-465,
490-498, 522-526, and 551-554). Change true to false and false to true so that
the tests verify the processor correctly recomputes the success field to reach
the expected outcome, rather than just passing through the pre-seeded value.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 0595327d-cf51-4c6a-9eb8-5104ff17d58a
📒 Files selected for processing (3)
src/core/src/processor/executor.rssrc/core/src/processor/executor_tests.rssrc/core/src/processor/incremental_tests.rs
Summary
Decouple assertion evaluation from runner, following strict TDD (Red-Green-Refactor) with micro-commits.
Changes
Runner decoupling (already present on main)
runner/executor.rs: ReturnsVec::new()forassertion_results— no assertion logicrunner/executor_async.rs: Same, no assertion evaluationrunner/response_processor.rs\':build_temp_result_for_assertions` removedProcessor assertion evaluation (verified via TDD)
processor/executor.rs—process_single_requestevaluates assertions after executor callprocessor/incremental_loop.rs—process_requests_incrementalevaluates assertions after executor callNew integration tests
processor/executor_tests.rs: 3 new tests verifying processor evaluates assertions on raw executor resultsprocessor/incremental_tests.rs: 2 new tests verifying incremental path evaluates assertionsTDD Cycle
Testing
Summary by CodeRabbit
Release Notes