PhraseryPhrasery homeGet Phrasery
Tests & QA21 categories

Decide unit or integration for this code

When you are not sure whether to mock the boundary or cross it.

Longstrategyunitintegration
Help me decide what level to test the code below at.

1. Identify the real seams: where the logic is, and where it meets something external (network, database, filesystem, clock, other services).
2. Say which parts deserve fast unit tests, because the logic is intricate and the input space is large.
3. Say which parts must be integration tested, because the bug would live in the interaction rather than in either side. Configuration, serialisation and queries almost always fall here.
4. Name what would be tested twice, and which of the two to delete.
5. Give the approximate shape: how many of each, and what the one end-to-end test should cover if we only get one.

Give a recommendation, not a discussion of the testing pyramid.

Code:

Making it yours

  • Paste your own material where the prompt asks for it. Everything above that line is instruction, not content.
  • Delete any rule that does not apply to you. A shorter prompt that fits beats a thorough one that does not.
  • If the answer comes back vague, add a line saying what you do not want. Constraints work better than encouragement.

Test strategy. Unit or integration, what to skip, fixture design, and pruning a suite that costs too much.

Related prompts

Keep this one

Phrasery saves prompts with a right-click and puts them back the same way. Add this to your own library in one click.

Add to your browser โ€” free