Repaso
EspaƱol
TestingFoundationsTST-42

Why do developers write tests?

Options

  1. To check the code works as expected, early on (Correct option)
  2. To make the program run faster in production
  3. Because every compiler requires them to build
  4. To increase the total file size of the program

Answer

To check that the code behaves as expected and to catch problems early, especially when the code changes later

Why

Without tests, every change might silently break something else and you only find out when users complain.

With tests, you run a command and see in seconds whether the important behavior still works.

Tests also act as living documentation of how the code should behave.

Remember

Tests = a safety net for changes.

Key terms

Practice this question in Repaso