test: framework integration tests + mock RPC server (#16) #31
No reviewers
Labels
No labels
area:assertions
area:cli
area:client
area:harness
area:meta
area:reporting
area:runner
type:user-story
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
charles/ws-rpc-test!31
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/16-mock-server-tests"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #16. Stacked on #30.
Summary
Adds
tests/framework_tests.rs: a separate integration test crate that exercises the framework's public API end-to-end against an in-process mock server. Complements the per-module unit tests (insrc/*.rs) which already cover internal invariants.Fixtures
spawn_health_server()— raw HTTP 200 responder on an ephemeral portspawn_mock_rpc_server()— tokio_tungstenite accept loop speaking JSON-RPC 2.0 with a small vocabulary:ping/<anything>→ echoes method + params (default path)fail→ JSON-RPC error-32601notify→ emits N notifications, then responds{sent: N}(exercises the race-prone path from #7)list_items→ 3-element array forassert_array!harness_for(health_port, ws_port)—ProcessHarnesspointed at the fixtures with a short health deadlineIntegration tests
end_to_end_happy_path_with_runner_and_hooks— runner withbefore_all+after_all+ three tests coveringcall,assert_ok!,assert_array!, and RPC error handling; verifies the lifecycle orderend_to_end_filter_limits_which_tests_run—"gallery*"filter, one test counted as filteredend_to_end_subscribe_and_wait_for_event—subscribe+call("notify", ...)+wait_forwith predicateend_to_end_call_and_wait_is_race_free— uses the notify-then-respond handlerend_to_end_fail_fast_short_circuits—fail_fast = true, asserts skipped countChecklist (from issue #16)
Mock server
fail,notify,list_items, default echo)notifymethodSelf-tests
RpcClient::callhappy path + JSON-RPC error path — exercised viafailmethodsubscribe+wait_forwith predicatecall_and_waitrace-prone path (server emits event before response)before_all,after_all)assert_ok!,assert_field!,assert_field_exists!,assert_array!)Performance
Test plan
just qagreen locally — 94/94 tests pass (89 unit + 5 integration)cargo test --test framework_testsworks in isolationNotes for the reviewer
RpcClientmethod / every assertion macro / every hook failure path lives in the per-module unit tests. The integration file verifies that the public seams fit together, nothing more. Adding more coverage here would just duplicate what unit tests already prove.pubfeature of the main crate (the issue allows eithertests/mock_server.rsorsrc/testing/mock.rs behind a feature). A separate test fixture is lighter weight and doesn't grow the library's API surface.futures-util,tokio,tokio-tungstenite,serde_json).use ws_rpc_test::{...}, which proves the prelude re-exports from #1 all resolve correctly for external consumers.Adds tests/framework_tests.rs: a separate integration test crate that exercises the framework's public API end-to-end against an in-process mock server. Complements the per-module unit tests in src/harness.rs / client.rs / runner.rs / assert.rs which already cover internal invariants. Fixtures - spawn_health_server: raw HTTP 200 responder on an ephemeral port - spawn_mock_rpc_server: tokio_tungstenite::accept_async loop speaking JSON-RPC 2.0. Handles a small vocabulary: - ping / <anything> → echoes method + params (default path) - fail → JSON-RPC error code -32601 - notify → emits N notifications then responds {sent: N} - list_items → returns a 3-element array for assert_array! - harness_for(health_port, ws_port) builds a ProcessHarness pointed at the two fixtures with a short health deadline. Integration tests (5 new in tests/framework_tests.rs) - end_to_end_happy_path_with_runner_and_hooks: runner with before_all + after_all + three tests exercising call, assert_ok!, assert_array!, and server error handling. Verifies the full lifecycle order. - end_to_end_filter_limits_which_tests_run: name filter "gallery*" counts one test as filtered. - end_to_end_subscribe_and_wait_for_event: subscribe + call("notify") + wait_for with predicate. - end_to_end_call_and_wait_is_race_free: uses the notify-then-respond handler to exercise the race-prone path from #7; asserts both call result and event params. - end_to_end_fail_fast_short_circuits: fail_fast=true, second test fails, third recorded as Skipped. These tests access ws_rpc_test's public API only — they live in tests/ so they compile as a separate crate, matching what end users would see. Same result as a doctest would give, with more end-to-end reach. just qa green: 89 unit + 5 integration = 94/94 tests, fmt + clippy -D warnings clean. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>Review — tests d'intégration framework + mock RPC server (#16)
Isolation publique correcte
Tests dans
tests/→ crate séparée → uniquement la surface publique dews_rpc_test. Exactement la bonne approche pour valider les seams end-to-end.Mock server
spawn_mock_rpc_server()supporteping,fail,notify,list_itemset echo-passthrough. Bien aligné avec les besoins des tests. Code dupliqué avec les helpers unit-test — acceptable pour des tests d'intégration qui doivent être auto-contenus.Couverture
end_to_end_happy_path_with_runner_and_hooks— vérifie les hooks + 3 tests dont un qui valideassert_array!.end_to_end_filter_limits_which_tests_run— filtre par nom.end_to_end_subscribe_and_wait_for_event— subscribe + wait_for en end-to-end.end_to_end_call_and_wait_is_race_free— le cas le plus important : notification émise avant la réponse RPC.end_to_end_fail_fast_short_circuits— fail-fast vérifié.Minor
spawn_health_server()etspawn_mock_rpc_server()sontpubdans un fichiertests/. Si d'autres fichierstests/*.rsarrivent, les déplacer dans untests/helpers.rsavecmod helpers;serait plus propre. Pour l'instant c'est OK.Aucun bloquant.
✅ Pas de bloquant — tests d'intégration bien isolés sur la surface publique, couverture des cas critiques (call_and_wait race-free, fail-fast).
b1819a8810to469a515e9e