Success with test-driven development starts with trusting the process. The classic process goes like this:
Create a test. The test should be short and test for one thing in your code. The test should run automatically.
Make sure the test fails. Verifying the test failure before you write code helps ensure that the test really does what you expect.
Write the simplest code that could possibly make the test pass. Don’t worry about good code yet. Don’t look ahead. Sometimes, write just enough code to clear the current error.
After the test passes, refactor to improve the code. Clean up duplication. Optimize. Create new abstractions. Refactoring is a key part of design, so don’t skip this. Remember to run the tests again ...