My advise:

- Don't bother with RSpec's hype. I tried it and got me pissed off so 
many times. Don't care about autospec, it will distract you more than it 
will help. Test::Unit is much better to use. AWDWR has a good enough 
chapter to get you started.

- Use mocha to mock and/or stub your method calls so that you test 
objects as isolated as possible from other objects.

- rcov can come in handy to know what parts of your app are not yet 
tested. Be careful: 100% test coverage, doesn't mean your app is still 
correctly tested.

- Don't ever use fixtures at all! Run away from any person who tells you 
they are fine, even if he is famous and rich.

- Write your tests (even unit tests) so that they hit DB as least as 
possible. When tests have to hit DB such as :include or :joins, then 
setup sqlite in-memory for faster testing.

- I have tried plenty factories: Machinist, factory girl, etc. I even 
wrote my own, but once you understand how to write tests that don't hit 
DB, you'll discover you will probably not need a factory at all. Except 
when you must hit DB, it can be a little bit easier to insert valid 
objects in DB. But at the beginning don't bother.

- use a notifier plugin on your production server to catch any 
additional edge case you haven't thought of (I use getexceptional), and 
write tests to prevent against them in the future


Writing tests is easy when you know how to write them and which tools to 
use.

Remember to have fun. If you are not having fun (even writing tests) 
then something is wrong.
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to