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 User Authentication with Rails Adding User Support to Our Application Simplifying Tests with Factories

For startups, does test-driven-development make sense?

If creating your MVP takes time X and adding tests takes time Y = 2X and every time you make a change to your MVP it takes (X + 2Y) =5X you're spending 80% of your time updating your complex test suite instead of pivoting and creating a great MVP - sounds like a recipe for a really, really expensive failure. Hardly lean development.

Tests only make sense to me after you're funded and have a working MVP and you re-write the code base from scratch.

Does anyone have an opinion on this that differs or actual experience in startups with testing?

7 Answers

Ethan Lowry
PLUS
Ethan Lowry
Courses Plus Student 7,323 Points

Well written tests today save you a lot more time later when things inevitably go bad in some way, regardless of your business.

It's really more about the fact that TDD allows you to write code with confidence, and be able to refactor / modify/ upgrade that code later safe in the knowledge that your solid test suite will guarantee that you your product still does everything it needs to do.

I found my self asking the same question. While learning (or trying to learn) the base code and functionality, TDD really confused me. I went to the rails guide, downloaded it to my kindle and built their app without all of the extra test code. I learned the code.

Once one knows the code and understands the relationships, then TDD makes sense. As stated by Ethan, TDD allows you to rewrite and alter with confidence that your test suite will maintain base functionality.

Personally, i am not sure that teaching a new development suite (Rails) using TDD is a good idea.

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

What Ethan and Robyn said. This seems like a lot of work now, but once you implement authentication and adapt the tests for it, new major features should not force you to modify this whole base test suite that much. And every time you make something new, you just run all the unit and integration tests instead of sitting for hours and trying to do all this stuff manually in the browser, looking at logs and console to understand what exactly went wrong (or making someone else do that). However this should not be the focus of a course for people who are just starting. I haven't really done the whole Odot course until recently because of this TDD focus. I needed some more confidence on how Rails works and how RSpec tests really work. Once I went through some of the chapters of "Everyday testing with RSpec", I was ready to follow along Jason's tutorial, modifying a thing here and there to make it work with RSpec 3 and my perosnal preferences.

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

I believe that you can write the tests later, since you don't always know exactly how the new feature will look like under the hood. And there's nothing wrong with writing tests AFTER the code. What's important is to actually have them for later use. They also document your app, if written correctly, and may remind you what different parts of your app do and how they work. You may (I know I did) forget the details after getting back to your app after a few months.

I believe this is a relevant video that perhaps can impart some insights to your question. DHH briefly talks about rejecting TDD around the 53 minute mark.

I've also found myself questioning why do test-driven development. They don't actually tell you WHY in the tutorials here, they just tell you to do it.

I've been thinking about your question for a few days now. The magic that happens at around 10:00 here should answer it:

http://teamtreehouse.com/library/user-authentication-with-rails/password-resets-and-testing/integration-testing-forgotten-passwords

:beers:

Happy coding!

i know the discussion thread is old, but i'm sure there are a lot of people still asking the same thing. admittedly, there is no one who hates testing as much as me! i am actually watching this just for the tdd, and b/c i suck at them. but trust me, testing is an absolute must. i've written simple codes that had a lot of conditionals statements. on the whole, it looked as though my code was doing what it needed to do, but then when i set up a test to check for the conditions, i noticed that it wasn't hitting certain areas, like edge cases. without testing, it would have been really hard to pick that up. when you come across a failing software in the public, like say, going into bank online, you'd love to know that the application is getting tested daily automatically, b/c you wouldn't want to find that you can i can log into your account without a password suddenly. and if you decide to change some feature in the browser page in six months, you would still want to know that the functionality, is still all there. i'm here just to get stronger on tdd, b/c a lot of employers look for this as an asset. also, it is absolutely true that tdd does help you code more efficiently. i find that setting up the test takes more time than coding, but i think its worth that time.