2. WHY TEST?
○ Know that your code works…(and doesn’t
breaks anyone else’s).
○ Make deliveries and deploys more
stable….
○ Saves time (and pain) wasted on bug
fixing later…
○ Improving code designs and refactoring…
○ Reduce fear of failing...
3. TYPES OF TESTS (most common)
○ Unit Tests:
● Tests a small part of the application independently
from other parts; (Testing one class’s method);
○ Integration Test (Functional Tests):
● Tests different parts of the application working
together; (Testing a controller using multiple classes)
○ End-To-End Tests (E2E):
● Tests whether the flow of an application performs as
designed from start to finish; (Testing a login flow)
7. “When testing, face the code like a
complete stranger…
You have no idea how it does what
it should do…
But you know your expectations!
8. WHAT MAKES A GOOD UNIT TEST?
○ Unit tests should be:
● Easy to write;
● Easy to read;
● Fast;
● Not an integration test
■ No access to external resources (network,
databases, file systems, etc.)
17. WHEN TO USE EACH ONE
○ Unit Tests:
● Models
● Services methods that don’t have internal
dependencies;
○ Integration Tests:
● Controllers;
● Services;
● Repositories;
18. HANDLING DEPENDENCIES
○ Unit tests:
● Maybe you should
refactor it….
● Dependency
Injection;
● Mocking;
● Maybe it is an
integration test;
https://jtreminio.com/2013/03/unit-testing-tutorial-part-4-mock-objects-stub-methods-depen
dency-injection/