What is TDD? (3)
What’s an interesting characteristic of TDD?
Will often roll back the code and write the update code again instead
of spending a long time debugging a single piece of code
What are the steps of the TDD cycle? (6)

What is a code coverage analyzer?
A tool to tell you what parts of a program have actually been active
What’s the idea of code coverage?
Infrequently-used statements in a program can hide bugs for a long time, so we want to figure out how to actually use everything
What is a test double?
A generic term for any case where you replace a production object for testing purposes.
Why do we use test doubles?
Sometimes it’s not possible to unit test certain code because of the unavailability of an external dependency (e.g. a database)
For a test double, when can the substitution be made? (2)
What are the types of test doubles?

How are test doubles done at runtime for

What is monkey patching?
“dynamic modifications of a class or module at runtime, motivated by the intent to patch existing third-party code as a workaround to a bug or feature which does not act as desired”
Applications of monkey patching (4)
–stub out a function for testing
–modify behavior of third-party code without forking that code
–apply a run-time patch
–distribute security fixes
What are dangerous things to be aware of regarding monkey patching? (3)
Describe how to monkey patch in the case where you want to replace a function

Why would you wrap a function when monkey patching? (wrapping is a subcase of monkey patching)
To add code that executes before and/or after an existing function
In the monkey patching case where you wrap a function, what happens when the patch function is invoked?
What happens if you forget to return the stored result of the original function, when wrapping a function for monkey patching
anything relying on the function’s return value breaks
In the case of wrapping a function for monkey patching, how do you unwrap the function (aka undo the monkey patch)?
–store the copy of the original function pointer you made before applying the patch back into the function pointer
What are 3 unit testing modules in python?
What are high level descriptions/characteristics for
unittest:
doctest:
mock:
Describe how to use unittest

Describe doctest (3)

Describe the mock module (2)
