System Testing |
Unit Testing |
Testing the complete application |
Testing individual components |
Analogy: Verify a bicycle works by riding it |
Verify the tire doesn't leak. Verify the wheel is aligned. Verify the brake will stop the wheel from turning. |
run the main() method |
execute individual methods |
Isolating faults can be difficult: symptoms
can be far away from the cause. |
Isolating faults is easy because only a small amount of code is being exercised. |
Which is done first? Unit Testing. Make sure all the
components are working before you integrate them.
Manual Testing |
Automated Testing |
A human executes the program and uses their
eyes and judgment to identify discrepancies from desired
result. |
A computer executes the program and compares
actual result against expected result ("the oracle"). |
Very laborious and time-consuming |
Very fast |
Error-prone: relies on human observer |
Doesn't rely on human to verify results |
Often done ad-hoc ("on the
fly") with insufficient thoroughness |
Invites a systematic approach. |
How to automate?
Automate system tests with unix 'diff' command.
Automate unit tests with JUnit tool.
(See Pizza
Calculator example). (pdf)