Skip to content

Instantly share code, notes, and snippets.

@misostack
Created April 30, 2022 10:46
Show Gist options
  • Select an option

  • Save misostack/7ecb375948fd9acb4f91fee65e801247 to your computer and use it in GitHub Desktop.

Select an option

Save misostack/7ecb375948fd9acb4f91fee65e801247 to your computer and use it in GitHub Desktop.
Test Pyramid

TEST PYRAMID

Overview

image

Mike Cohn's original test pyramid consists of three layers that your test suite should consist of (bottom to top):

1.Unit Tests 2.Service Tests 3.User Interface Tests

  • Write tests with different granularity
  • The more high-level you get the fewer tests you should have

Unit tests

Your unit tests make sure that a certain unit (your subject under test) of your codebase works as intended

Solitary unit tests

All collaborators (e.g. other classes that are called by your class under test) of your subject under test should be substituted with mocks or stubs to come up with perfect isolation and to avoid side-effects and a complicated test setup

Sociable unit tests

Tests that allow talking to real collaborators

Only collaborators that are slow or have bigger side effects (e.g. classes that access databases or make network calls) should be stubbed or mocked

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment