identity_cache icon indicating copy to clipboard operation
identity_cache copied to clipboard

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

Open dylanahsmith opened this issue 4 years ago • 0 comments

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.

dylanahsmith avatar Jun 11 '21 21:06 dylanahsmith