I have been using ruby exclusively for about a month and I really love it. However, I am having an incredibly hard time using, or even learning TDD. My brain just doesn't function that way...
I really, really want to learn TDD but to be honest I am a bit confused. All the articles that I find when Googling around are mostly specific to Rails, which is not interesting to me because I want to learn how to do efficient testing for any ruby application, from the simple one-file script to the complicated gem, not for Web apps. Also, there are so many frameworks and so few tutorials to get started.
Could anybody give me any advice on how to learn TDD so that I can at least start to consider myself an aspiring rubyist?
Basically, TDD is hard! It needs skill, and it needs practice. The good news is that TDD rewards the effort. Once you get over the hurdle of working incrementally and writing fine-grained tests (hard), you'll find the implementation slots into place.
TDD in Ruby on Rails is a key practice in which the developer writes code first before writing the actual code to maintain the overall code quality.
Try RubyKoans.
The best way to learn TDD is by just doing it. I suggest you build a new project using TDD. This means don't write any non-testing code unless you have a failing test.
It will make you think about writing tests: I want to write this code, how do I write a test for it so I can write it.
It will show you the layered nature of testing. Instead of want a name that is required and can't contain numbers. you'll first test setting and reading a name, test requiring the name, test it shouldn't contain numbers, than think if it has more constraints and test those.
Remember:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With