- Find defects
- Check for right working
- Convince customer
- For yourself
- Early tests save money
- Excess testing does't exist
- Избыточного тестирования не существует
- Testing Sum(a, b): tested on (5, 4). (1, 2), (100, 500) is cringe
- Testing shows presence of defects, not their absence
- "80/20" rule
- 20% of code contains 80% of errors
- Old tests can't help in finding new mistakes
- Testing depends on context
- Absence of mistakes is delusion
- Unit tests
- For components
- Integration tests
- For checking component integration
- System tests
- Checking integration of all components (system test)
- Acceptance testing
- Difference with system tests: different aspects
- Loading testing
- Checkout system overloading
- Stress testing
- How long system can stay alive
- Scalability tests
- How system works with scaling
- Vertical scaling: improve system
- Horizontal scaling: buy more system units
- "White box" testing
- We know about system's structure
- There is also "black box" testing
- We don't know about system's structure
- Execution tests
- Mutation tests
- Testing of tests
- Static tests
- Ex: code review, linters: clang_tidy, clang_format
- Code coverage
gcov&lcov
- Statement coverage
void f(int a, int b) { int res = a + b; if (res < 0) { cout << res; } else { cout << -res; } }- Calls only
f(2, 3). Covered +- 70%
- Branch coverage
- Decision coverage
a = -3, b = -3if (a > 0 && b < 0)- DC is 50% because of lazy calculation
- Path coverage
- Checkout full path (combinations of branches)
- exp(if_count)