What is the difference between sociable and solitary unit tests?
Answer
Terms coined by Jay Fields (and discussed by Martin Fowler): Solitary unit tests (mockist/London School): test a single class/function in complete isolation — all dependencies are replaced with test doubles. Strict isolation ensures you know exactly what's being tested. Risk: tests may pass while the real integration is broken (heavy mocking can mask real bugs). Sociable unit tests (classicist/Detroit School): test a unit with its real dependencies (other units) where those dependencies are stable and fast. Only external I/O (databases, APIs, filesystem) is replaced. Tests reflect more realistic behavior. Risk: when a test fails, it's harder to identify which unit caused the failure. Which to choose: use solitary tests for units with complex logic where isolation is valuable (complex business rules, algorithms). Use sociable tests for coordinating units where the interaction matters (domain aggregates collaborating). Integration tests are always sociable. The debate is less about which is right and more about where to draw the isolation boundary.
Previous
What is the Outside-In TDD approach?
Next
What is trunk-based development and how does it relate to testing?