× {{alert.msg}} Never ask again
Receive New Tutorials
GET IT FREE

Steve Klabnik on the Future of TDD and Testing

– {{showDate(postTime)}}
Steve Klabnik Ruby on Rails ExpertSteve Klabnik, Active Rails Contributor

Steve Klabnik recently hosted an Office Hours with the Codementor community

Steve is an active Rails contributor and is currently ranked #32 on the all-time Rails Contributors list.

Codementor sat down with Steve Klabnik and the community earlier to answer some of your questions on TDD.

What is your testing strategy ?

Personally I like to write a lot more integration or feature tests, and only unit-test the more complicated parts of the code. For me the point of tests are to feel confident with making changes to your code, not so much to check if something works, so if a test doesn’t make me more confident in refactoring later, I just take it out.

Having a 100% test coverage, or unit-tests for every function, is not that necessary, it’s more important to have higher level tests to see how your code interacts with each other, allowing you to refactor, or change your code later and be sure you aren’t breaking anything.

What are your thoughts on DHH saying TDD is dead ?

First off, I think DHH saying TDD is dead, is an over generalisation and just an inflammatory statement. You can’t just decide TDD is dead, and it’s a fact that many people still program TDD in Ruby.

I think the statement was made to bring attention to the subject, and to get people questioning and discussing testing in general. When DHH says TDD he – in my opinion – is really referring to writing unit-tests, and he is right when he says writing these kinds of tests is difficult in rails, but I don’t think this is an intrinsic flaw of TDD rather a fault of Rails itself.

Resources to learn about writing concise Ruby code and about testing

Russ Olsen’s book – Eloquent Ruby – is a really great book with lots of patterns on how to solve things “The Ruby Way” and you can learn a lot about writing idiomatic and concise Ruby code.

Another thing is that there are not enough open source Rails apps most examples go too far with tests, and are more for “academic” purposes, but they aren’t always practical. I actually just started a real world Rails app that I am making for a friend, and I have the code up online Artisan Assistant, open-source, for people to see how I like to set things up, and my opinions on testing. I do a lot more feature tests, then lower level unit-tests.

After you are comfortable with testing the best thing you can do is look at other popular repositories to see how they deal with real world problems.



Author
Steve Klabnik
Steve Klabnik
Active Ruby on Rails Contributor
I work on many open source projects. I have 273 repositories on GitHub, and am in 15 organizations. Some of them are huge, like Ruby on Rails. Some of them are small, like my own little side...
Hire the Author

Questions about this tutorial?  Get Live 1:1 help from Ruby on Rails experts!
Itamar Yunger
Itamar Yunger
5.0
I am a Ruby on Rails Developer programming in Ruby, JavaScript, HTML/5, AJAX, CSS on Linux / Apache / MySQL / Ruby / MongoDB / Python / Amazon /...
Hire this Expert
Michael Stromberg
Michael Stromberg
Senior software developer with 7 years of experience
I used to build hardware, and now I build software. Although I have had a winding career path in multiple disciplines, I have always enjoyed...
Hire this Expert
comments powered by Disqus