All quizzesHard
Advanced Testing — Series 3
Preview — 3 of 10 questions
What does a good test suite for this cover?
javascript
OrderPlaced → reserve inventory → capture payment → ship
Each step has a timeout and a compensating action.AOnly the happy path, since the compensations are simple by construction
BOnly the compensations, since the happy path is covered by the individual services
CThe whole flow through real services, to be faithful
DThe state machine in isolation, driven by events and timer expiry: the happy path, each step failing, each timeout firing, and a compensation itself failing — because the transitions are the logic, and the timeout branches are the ones that never run in manual testing
How do you test that redelivery is harmless?
javascript
@EventPattern('payment.captured')
async handle(@Payload() event: PaymentCaptured) { /* ... */ }ASend the event twice and assert the handler was called twice
BSend the same event twice — identical id and payload — and assert the observable effect happened once: one ledger row, one balance change, one outbound notification; calling the handler twice is expected, and having no second effect is what idempotency means
CConfigure the broker to deduplicate and assert it did
DAssert that the second call throws a duplicate error
How should the two be used?
javascript
(1) An in-memory transport double the application publishes to
(2) A real broker started for the test runAThe double for the majority of tests — fast, deterministic, easy to assert on what was published — with a small number of tests against a real broker to cover what the double cannot model: acknowledgement semantics, redelivery, dead-lettering and ordering
BOnly the real broker, since a double proves nothing
COnly the double, since broker behaviour is the vendor's responsibility
DNeither; messaging should be tested manually in a staging environment
Sign up free to play
Answer all 10 questions (7 more), see explanations for every answer, and track your score.