TestRunner: before_all, before_each, after_each, after_all hooks #10
Labels
No labels
area:assertions
area:cli
area:client
area:harness
area:meta
area:reporting
area:runner
type:user-story
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
charles/ws-rpc-test#10
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
User story
As a test author, I want lifecycle hooks for fixture setup and per-test cleanup, so that state can be reset between tests without duplicated boilerplate in every test body.
Acceptance criteria
runner.before_all(|client| async move { ... })— runs once after harness start, before any tests. Failure aborts the run with a clear error.runner.before_each(|client| async move { ... })— runs before every selected test. Failure marks that test as failed and skips its body;after_eachstill runs.runner.after_each(|client| async move { ... })— runs after every selected test, regardless of pass/fail. Failure is logged but does not change the test outcome (the original test result wins).runner.after_all(|client| async move { ... })— runs once after all tests, before harness stop. Failure is logged and surfaces in the report (report.after_all_failed: bool) and exit code.Arc<RpcClient>and returnimpl Future<Output = TestResult>.Why all four
The original spec only listed
before_eachandafter_all, which leaves common patterns awkward:before_allfor one-time fixture seeding (resolves spec review §4).after_eachfor per-test cleanup that's better done after rather than before (resolves spec review §5).References