Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Build a Todo List Application with Rails 4 Build a Todo List Application with Rails 4 Write Our First Tests

Max Alexander
Max Alexander
7,258 Points

Is setting up testing necessary? If so, is this method commonly used by Ruby on Rails developers?

I'm intrigued to know if it's really necessary?

Let's say I build an application without the testing methods in this course, can't I just test the application through use of the application through the browser?

I'm well aware I'm a naive developer, hence why I am here! I'm just interested to know outside of this course how often this format of testing is used.

Thanks a lot for your help guys and girls!

2 Answers

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

You would have to test EVERY single feature in the browser after every major change in the code. Once you have 20 features, good luck with doing all the tests manually every few lines of new code are added. If you write tests for it, they will do the job for you every time. Testing in the browser (taken care of by Capybara) is not the only thing you should do. There are also lower level tests, such as controller and model tests, so you would have to do them manually in rails console after every major change. Again, wasting a lot of time.

Test-first also lets you think about the problem you are facing before you actually implement the solution.

And in Rails world, this is the default approach - TDD. Everyone does it or at least should do it. Sure, you can also write tests after doing the code for the given feature, it's probably easier at first. But it's important to write them constantly, not after the app is ready (the waterfall model is sooo 1970...).

Max Alexander
Max Alexander
7,258 Points

Thank you for the input Maciej! You make a lot of sense!

Robert Ho
PLUS
Robert Ho
Courses Plus Student 11,383 Points

I know of companies who have QA teams that manually test on the browser and do not have unit / integration tests on their systems/products/services. While I think it is good to have a working knowledge of testing on all levels, I don't believe it is necessary to always test for EVERY method and function in all your applicatiosn. Sure there can be times when you have some complex methods and you want to be sure they are working correctly, so you make some tests for them. But I see people testing for trivial things all the time (user has_many posts?) and yes you can have them there but it's not the end the world if you don't. Even the creator of Ruby on Rails, DHH, said it himself that Test-Driven Development is Dead. If you work in a professional setting, you won't have time to make unit-tests for every single method you are creating. You will have deadlines and clients howling for things to get done, so at minimum you would want to at least test for the "behavior(s)" of your application. Just my 2 cents!