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 trialMax Alexander
7,258 PointsIs 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
36,441 PointsYou 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...).
Robert Ho
Courses Plus Student 11,383 PointsI 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!
Max Alexander
7,258 PointsMax Alexander
7,258 PointsThank you for the input Maciej! You make a lot of sense!
John Steer-Fowler
Courses Plus Student 11,734 PointsJohn Steer-Fowler
Courses Plus Student 11,734 PointsThumbs up +1, very well explained