- Introduction
- Part 1: Why use it?
- Part 2: Write My Tests First?
- Part 3: Keys to Effective TDD
- Part 3, Key #1: Write Testable Code
- Part 3, Key #2: Write Good Tests
- Part 3, Key #3: Using Fakes and Dependency Injection
- Part 4: Conclusion
When I first started using TDD, it was a struggle. My tests seemed as complicated as the actual classes I was trying to write, and I didn’t really feel like I was getting a lot of benefit from the tests.
When I would change some code that would cause a test to fail, I didn’t really have confidence in the test. So instead of fixing the code, or refactoring the test to meet the new functionality, I would sometimes end up just commenting out the test itself.
Not very useful.
Not to mention maintaining all of my “mock” classes, such as repositories, that would contain enough data and functionality to make my tests useful. It was a headache and found myself nearly giving up on the practice.
But over time, I realized a few key items that helped make TDD more effective.
- Write Testable Code
- Write Good Tests
- Use Fakes and Dependency Injection
I’ll expand on these three points in my next three posts.
0 comments:
Post a Comment