Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Unit testing

Unit testing

A brief summary about the importance of Unit Testing.

It was part of an Unit Testing workshop I presented last February 2019.

Francisco M. González

February 18, 2022
Tweet

More Decks by Francisco M. González

Other Decks in Programming

Transcript

  1. What’s Unit Testing? - Less bugs due to changes -

    Less maintenance time - Easier refactors - Provides confidence
  2. What should NOT be covered? - Third party services (never

    use third party services in tests) - Some robustness checks - Framework itself - PHP itself
  3. What is coverage? - It’s only another metric - As

    all metrics we can set a goal - 80-20 rule - Set an agreement between quality (confidence) and effort (costs) - It’s a gamification tool for developers
  4. Pros and Cons - Provides confidence - We need this

    kind of confidence so we need tests - Get 100% of coverage has a high cost not only in effort, also in maintainability - It’s only a metric, a selfish one.
  5. Proposal - As a normal tests definition: - Test requirements

    - Test controlled errors - Set an approval level of coverage (90%) - Don’t use third party services in your tests. Mock them