Unit testing is based on the red-green-refactor cycle, which is a fundamental idea. Writing a failed test (in red), altering the code to make it pass (in green), and then reworking the code to maintain the tests passing are all required.