Creating spies in code