QA16 Testable Code
What makes code testable?

Ensure segmented
Ensure events are repeatable

Fewer parts means more testable
(might have multiple global values, or related routines)
Fix:  for each routine, make a ‘stunt double’
{global variables can make it harder to test code)
Side effects: routine can change something for a different routine

Black box code is very hard to make testable
GUI very hard to test

Write tests up front
(make sure code can be tested, make sure tests are relevant to the code)

DRY Do not Repeat Yourself
(Look for code that has been written that can be generalized)

Dependency Injection
Rather than hard code, pass a parameter

TUF test unfriendly features
TUC test unfriendly constructs

Database manipulation is very hard to test

Legacy code:
Might need refactoring
Pinning current tests
Focus on feature adding or bug you fixing
Recheck against pinned version

Refactoring whole legacy system can be too time consuming