Rake is my new F5 17

The last couple of days I’ve been doing a bunch of refactoring, as I tend to do whenever I’ve reached a kind of plateau on what I’m working on. It’s always good, once things work, to go back and improve the design.
I try to write tests before I write code, so that I’m guaranteed to have tests for every feature. I can run those tests at will to make sure my code works. If I couldn’t do that, I’d be much more reluctant to change anything once the code works, for fear I’ll break something important but not really know it until it’s too late.
But it’s funny how old habits – like pressing F5 in Visual Studio 2005 every time I made a change, just to make sure the app still compiled and worked ok – die hard. Really hard. After I made all these changes in my Rails app, my first instinct was to “run” it and make sure nothing broke. Because Ruby does not have a compilation phase, one typo in a local variable name can go undetected until runtime.
Then I remembered my tests and realized I can just run all my tests to make sure that the app still does what I want it to do:
/dev/app$ rake
All my tests still passed, and it felt great.
Now, I’m not egomaniacal enough to believe that I have perfect test coverage, so I still fired up script/server and manually put the app through its paces. But knowing that the full regressions suite passed made a big difference when it came time to pull the trigger and check in all of my changes.
I’m probably in the minority, here. I know that writing tests is not something everyone does, and writing tests first is less common still.
I’m curious to know what you all do. Does running your app in a browser feel sufficient for you? Do you write tests? Do you wish you wrote tests? If so, what stops you?



dude, autotest via ZenTest and (optionally) use rspec. Then your tests are continually running and you know as soon as something breaks. You can also test all your views, etc. so you never even have to fire up your browser. Spending less time in the browser makes me more productive.
Again, rspec is optional, but I have much love for it. Its changed the way I think about testing. Now I test how my code should behave instead of testing how my code works.
Exactly, what Jeffrey said. Autotest is like a super duper little build monkey who throws poo whenever your tests fail.
Despite all the tools in the world which empower us to do so, a lot of people still don't write tests at all. And like Jeff said, test-first is even less common.
@jeffrey +1
don't forget to add growl notifications to autotest!
I'm not always good about writing a test first but I at least write a pending test to remind me to go back and write the test.
I suppose I'm somewhat in the minority in that I choose to not use rspec or autotest. Actually, my process involves both tests and the browser. I'm fanatical about unit testing. Functional testing is important, but I try to build my apps for most things to be tested as unit tests. And testing views seems somewhat ridiculous to me, for whatever reason. They're extremely brittle (I don't think changing markup should ever make a test fail).
And I'm also the "designer" too, so I definitely spend a large amount of time in the browser, considering IE is dumb and doesn't listen to standards. But even if I wasn't the designer, I would still fire up the browser for reassurance; I'm not the point where a passing test suite gives me 100% confidence that my application is flawless. Tests are only as good as the person writing them, and I'm sure I don't cover everything.
"Do you write tests? Do you wish you wrote tests? If so, what stops you?"
No, I don't write tests.
Yes, I wish I wrote tests.
The decision makers at my company apparently don't have an appreciation for unit testing, much less TDD. (And yes, I've tried to push for it.)
autotest + redgreen + growl is like playing a video game about writing code. SWEEEET!
Autotest FTW!
I'm a rails ruby, and just learned about rspec at our local ruby meetup yesterday. From my perspective (which will probably change once I start using rspec), it seems that you duplicate your effort by testing then coding (or vice versa). This leads me to wish for a workflow where you do both simultaneously, so that by define what your code should do (writing your tests), you actually write your code. But again, once I start using rspec, I might change my mind.
I'm a rails nuby, and just learned about rspec at our local ruby meetup yesterday. From my perspective (which will probably change once I start using rspec), it seems that you duplicate your effort by testing then coding (or vice versa). This leads me to wish for a workflow where you do both simultaneously, so that by define what your code should do (writing your tests), you actually write your code. But again, once I start using rspec, I might change my mind.
Should I give up on Rails+Windows? I don't know how to get autotest+zentest+rspec+redgreen working!!! Arrgh.
+1 for autotest...
And yes if you are on windows you should switch to *nix if you really want to be a serious rails developer. I gave up on it a long time ago (windows+rails) and life is much easier.
If you're using autotest on Mac OS X Leopard you might be interested in taking advantage of the new FSEvents feature...
Taming the autotest Beast with FSEvents http://rails.aizatto.com/2007/11/28/taming-the-autotest-beast-with-fsevents/
No autotest here as I still code a lot of classic ASP, ASP.NET, PHP and Delphi (yeah, my brain hurts some days) but testing is a must. I tend to do test-first because trying to use the methods before they're coded helps me figure out naming conventions, parameter lists and various interactions.
I also have a CruiseControl continuous integration server so on each subversion commit all the tests get run. I also try to do more atomic commits vs. the old "here's what I've been working on for the last week" and then watching 100 files go zooming into the repository. If I'm working on something major I branch and make sure my integration server runs tests on that branch.
I believe if the person wants something - nothing can stop him!
if you think your tests cover all your code Heckle (http://ruby.sadi.st/Heckle.html) them.
--R
Because of the relation between philosophy and the phenomena, the things in themselves (and I assert that this is the case) constitute the whole content for our ideas; for these reasons, the discipline of practical reason proves the validity of the phenomena.