Shopify / Shopify/identity_cache

Reorganize unit test files to match the structure of the code under test

Open
#498 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

refactor
Dominant language
Ruby
Stars
2k
Forks
174
Avg merge
13m
Merged PRs (30d)
3

Description

Currently, it is hard to determine where a test should go, since a lot of the test files are organized around overlapping features, resulting in multiple places that could seem like the right place for the tests.

This disorganization can make it harder to:

  • find where to put a new test
  • notice duplicate tests
  • determine if a code path is tested
  • run the relevant tests for a code change

I think this disorganization largely came from the disorganization of the code under test (https://github.com/Shopify/identity_cache/issues/497).

Instead, tests for a code path in the code under test belongs in a test file with a corresponding name and in a test name prefixed with a corresponding test name prefix. Note that a test can be for a code path in a method without directly calling it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing unit-test files alongside the code under test, then read the linked restructuring issue #497 to understand the intended code layout. Reorganize tests so each code path has a corresponding test file and test-name prefix; done means the test location is unambiguous and the relevant suite still passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
testing
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.