Uncle Bob's three rules of test-driven development
Here are some guidelines to Test-Driven development (TDD):
- Only write code to make a test pass
- When writing a test, write the minimal to make a test fail; this includes your code not compiling
- Write the minimal amount of code to make a test pass
With that said, the other rule of thumb is Red-Green-Refactor.
Red-Green-Refactor
Write a test; if that doesn't compile, this is red. Make it pass, that is your green. Then refactor the code, not the unit test, to your heart's content, that is your refactor.
So red, green, refactor, that should be your mantra.
I know I have already started the production code in the preceding chapters. If this was a book about TDD, then I would have started with the test. Our aim has been to introduce ASP.NET Core 2.0.
We will go back to our example that we started off with, Puhoi cheese, and I will recap that we are storing and can retrieve a few stores that we have. A store has a description and the number of products that...