What is Test-Driven Development?
Test-driven Development (TDD) is the process of writing your tests before you write your code for a new feature or to implement a new fix.
Under TDD, you first write a test for the feature you’re trying to implement or a test to reproduce the bug you’re about to fix. You do this in the most ideal way possible, which may even involve classes or methods that don’t exist at the start of your test.
Next, you do the minimum amount of work needed to make your code successfully compile. This isn’t to say that it runs perfectly or does the thing it is trying to do, in fact, you’re trying to start out with a red failing test that indicates your feature or fix doesn’t work.
This makes sense when you consider that at this point you haven’t implemented the new feature or made the fix to the code. So, the test should be a failing test.
Next, you write the minimum amount of code required to make your test...