Herramientas de usuario

Herramientas del sitio


code:tdd

¡Esta es una revisión vieja del documento!


TDD (Test Driven Development)

Basics

Best Practices

  • Have separate source and test folders. Test code should follow the structure of source.
  • Test should fail the first time it’s written/run.
  • Test names should reflect intent, and names should be expressive.
  • Refactor to remove duplicate code after passing test.
  • Re-run tests after every refactoring.
  • Only write new code when a test is failing. Each test should test new/different behavior.
  • Write the assertion first.
  • Minimize the assertions in each test.
  • All tests should pass before writing the next test.
  • Only refactor when all tests are passing.
  • Write the simplest code to pass the test.
  • Don’t introduce dependencies between tests. Test should pass when run in any order.
  • Tests should run fast. A slow test is a test that won’t get run.
  • Use mock objects to test code at system boundaries (e.g. database, container, file system) so that tests run fast.
code/tdd.1380213234.txt.gz · Última modificación: 2020/05/09 09:24 (editor externo)