• nous@programming.dev
    link
    fedilink
    English
    arrow-up
    1
    ·
    3 years ago

    In unit testing, a “unit” does not have to be the smallest possible section of code. It can be a while class or module or even set of related classes/modules. Testing individual functions in isolation leads to brittle tests that easily break during refactoring. Testing overall system behaviour results in more robust tests that require fewer changes during refactoring which gives you more confidence then you have not introduced a regression.

    • asyncrosaurus@programming.dev
      link
      fedilink
      arrow-up
      1
      ·
      3 years ago

      This is the correct comment.

      Martin Fowler called them sociable tests. The only way to properly test your units’ behavior is to pull in their dependencies. Isolated tests are useless, brittle and slow to write.