The document discusses how unit testing can make software development faster. It explains that unit testing finds bugs early, enables easy refactoring by verifying code changes don't alter functionality, and serves as documentation through examples of how code units work. The document also defines a unit as the smallest testable part of an application, describes common unit test structures across frameworks, and provides examples of test-driven development and how tests influence code architecture and act as documentation.
5. Why testing makes development faster (cont...)
Dev cycle - without unit testing
Design Write Code Verify it
works
QA
6. Why testing makes development faster (cont...)
Dev cycle - unit testing after code is done.
Design Write Code Verify it
works
QAWrite tests
7. Why testing makes development faster (cont...)
Dev cycle with test automation (TDD)
Design Write code +
tests
Verify it
works
QA
8. Other benefits
Unit tests at the foundation of good software, some of the benefits:
1. Discovers bugs early
a. Test failure indicates some part is not working as intended, which usually means a bug.
2. Makes refactoring easier
a. Change the unit internals without changing its interface & behavior.
3. Documentation
a. Text docs are often neglected as the code grows.
b. Unit tests supply small working examples for our unit in action, that is always up to date.
4. Design
a. Complex code leads complex tests.
9. What is a unit?
The smallest testable part of an application (wiki)
● Entire module
● Single function
10. It doesn’t matter which test framework we use, the test structure is pretty much the same
● Senario (describe/context/testsuite...)
○ Setup (before/beforeEach/beforeAll...)
○ Tests (it/should...)
○ Tear-down (after/afterEach/afterAll...)
Some frameworks support nesting scenarios.
Unit test structure