Testing Architecture — Series 3

Preview — 3 of 10 questions

A test asserts that paymentGateway.charge was called exactly once with the right amount, and it also returns a canned success response. Which doubles are in play?

AOnly a spy, since the assertion is about calls.
BOnly a fake, since it stands in for a real service.
CA stub (it supplies a canned answer so the code under test can proceed) and a mock (the test verifies the interaction). A spy only records; a fake would be a working lightweight implementation.
DA dummy, because the object is passed but never used.

The trophy shape favours integration tests over the pyramid's unit-heavy base. On what grounds?

AThat tests exercising several units together give the most confidence per unit of cost, because they cover the wiring where bugs concentrate — while modern tooling has made them fast enough that the pyramid's cost argument no longer dominates.
BThat unit tests are worthless and should be deleted.
CThat E2E tests should be the largest layer.
DThat static typing replaces the need for tests at the lower layers.

Ten independent boolean flags produce 1024 combinations. What is the practical strategy?

ATest all 1024 combinations nightly.
BTest only the all-off and all-on configurations.
CTest each flag individually and assume combinations compose.
DTest each flag in isolation, add pairwise coverage — since most interaction bugs involve only two flags — plus the specific combinations that are actually shipped or planned, and keep the flag count bounded by removing flags once rolled out.

Sign up free to play

Answer all 10 questions (7 more), see explanations for every answer, and track your score.