13 unit testing

test smallest units; e.g. functions,methods, objects.
Often not directly visible to user.
Usually done by developer.
Ideally; this shows individual components work;
other tests show how system as a whole works.

Advantages:
Problems are found earlier. 
Faster turnaround time. 
Faster runtime than systems-level tests. 
Developers understand their code.
Living documentation. 
Alternative implementation. 
(extra check on how code should work)
Able to tell if code changes caused issues elsewhere.

Example: linked list comparison.
(Note that with linked lists, it is EASY to accidently compare memory instead of data, which means it would respond with not equal.)
Preconditions: 
Execution Steps: 
Expected Behavior: 
verify observed behavior:

Junit testing framework used in book
(TestNG, Jtest,cucomber-jvm also available for Java.)
CONCEPT important for class.
Junit fails ONLY if an assertion fails.
(So remember to put assertion in)

Compare nulls
compare pointer to itself
compare single item to single item
compare with link field unintialized
compare list of 2 or three items, sorted and unsorted
try a recursive or circular linked list
see if it works for a tree
see if it works for a doubly linked list
see if it works for a circular doubly linked list with a header

hard to test for absence of a behavior
check to make sure your test actually fails
(Start with <> instead of ==, for example)

make sure YOU understand what code is to do;
(check understanding with end user)

ANY behavior other than returning a value is called a 'side effect'.
Side effects, especially unintentional ones, can make debugging VERY difficult.
(no side effects is called 'pure')
[even a (debug) print is considered a side effect]
Testing of 'pure' functions is easier, but NO program can be useful without affecting data or printing!

Also watch for functions that use global values or named constants;
if the global value changes, it changes how the function works!

If you are programming in an IDE, feel free to set up automatic testing.
If you can do testing with a script, that is great.