Trace shared state between TDD tests

During TDD, you develop an integer accumulator whose value starts at zero. Its addition and multiplication operations work correctly. Two tests pass when each creates its own fresh accumulator:

  • Test A adds 4, then asserts that the value equals 4.
  • Test B adds 3, multiplies the resulting value by 2, then asserts that the value equals 6.

A setup change makes the tests share one accumulator without resetting it between tests. The runner continues after any failed assertion, and assertions do not change the value.


Two execution orders each start with a fresh accumulator and then share it between two tests.


Find the actual value read by Test B's assertion when Test A runs first, and the actual value read by Test A's assertion when Test B runs first. Each execution order begins with its own fresh accumulator. Enter both values as exact integers, with no units.

Your answers

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Test-Driven Development Questions: