¡Esta es una revisión vieja del documento!
TDD (Test Driven Development)
Basics
TDD pipeline
Add test, escribir un test que utilice la funcionalidad que se quiere implementar.
Watch test fail, si la prueba no falla es que no es idónea, escogemos otra.
Write code, escribimos el código mínimo para que la prueba pase.
Run tests, hacemos el código funcional mientras vamos corriendo los tests.
Refactor, ponemos el código bonito.
Y volvemos a empezar…
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.