Define what Red, Green, Refactor is in the context of TDD and how it's implemented. Each step are clearly explained starting with Red and it's purpose for failing tests. Green is next with it's purpose of updating tests. Refactoring it touched on last to explaing the need to update code to coding standards and re-testing. Student should be able to apply Red/Green/Refactor steps moving forward when creating unit tests.
- In the context of test driven development the meaning behind the motto, red, green, refactor, breaks down like this. Red; you're creating a test that is purposely written to fail. That makes you confident your testing is going to fail when expected to. No point in having a test that can't catch bugs and always passes. Green; this is when you update your code in an application so your test passes. Refactor; here is where you beautify your code.
Your remove the duplicates, improve the design, make it easy to read, adhere to coding standards, and then rerun the unit test to make sure it still passes after all your changes. Red, green, refactor. Those are the steps and you repeat them for each unit test case. Now let's look a little deeper into what I mean by adhering to coding standards when refactoring.
In this course, Reynald Adolphe explains the principles of test-driven development and shows how to apply them to two different C# workflows. First, he creates a new test-driven project. He writes the test cases before the code to drive the design of the program. In the second scenario, he writes test cases for an existing C# project, to find bugs before it goes live. Along the way, Reynald uses Microsoft's MSTest, but he also introduces other testing tools (such as the unit testing framework xUnit and the mocking framework Moq) and theories (such as the red-green-refactor mantra and SOLID principles) that make test-driven development so efficient.
- Different approaches to testing
- Using testing tools and mocking frameworks
- Creating a simple C# test-driven project
- Adding a failing test
- Updating tests to pass
- Refactoring code
- Using Moq to test data