Ask HN: Should I employ TDD as a Rails beginner?
I've seen a lot of discussion about why TDD is good, and why some people feel that it's unnecessary in many circumstances. My understanding is that if you are writing a large scale application that will involve thousands of lines of code and will need maintenance for years, then yes, TDD is certainly a good way to go.
My question, though, is will TDD help me as a beginner to Rails when I am simply trying to get the core concepts and write small apps that get more experience under my belt. My intuition is that TDD is extraneous at this point and slows down the instant gratification factor that motivates me to do more and learn quicker. What are your experiences with it and did it abet your learning process?
8 comments
[ 9.5 ms ] story [ 42.9 ms ] threadI can't tell you the number of times I have made a change then run regression testing and found unforeseen failures which I wouldn't have caught without my test cases.
Now, I believe 100% test coverage is plain silly. There are things you don't really have to test, and you are the only one who can tell.
I just started building a new app, and haven't done any testing until I was half-way through the first iteration (what I considered to be my first public alpha). I wrote a few tests to make sure the functionality I'd implemented would still work when I changed the code, then I moved to a more TDD dev style.
I wrote a few (maybe 10) tests for things I wasn't sure how they'd behave, noticed I could fix some of my code.
So, TDD can help you, for sure. But don't get too caught up in writing tests if it's getting in the way of actually writing your code.
Agreed with this for sure. It makes maintaining tests unsustainable and time consuming to write. Cover your bases cases and make sure that important failure cases are covered. Don't try cover every possible iteration under the sun. I find that well written tests should almost read like executable documentation.
Writing tests for your models should have you covered. You can skip testing the controllers & views.
The longer you go without writing tests the harder it is to start.