Damnit, I'm tired of testing!
I lied! I love it and it's totally helpful in the long-run.
Bryan Liles came up with a cool acronym -- TATFT (test all the fucking time). As soon as I heard him talk about this at ActsAsConference2008, he instantly made the best possible answer to testing. It doesn't matter what framework you write your tests in as long as you write tests.
Below are some quick guidelines for your tests to try to make it easier for those that are getting stuck as to "how to test" or "what should my tests contain for this type of test". By no means are they the answer to all your problems, but somewhere that you can build off of:
Model tests:
- In rails, I would use rSpec or Test::Unit
- STRONGLY suggest not to use instance variables
- If you start to write any code that interacts with an object other than your model, something is wrong with your model, don't try to fix it with shitty tests
- In rails, I would use rSpec
- rSpec Storyrunner is nice, but *I* think it's a completely different realm for those that haven't been used to writing tests for very long
- Try not to hit the database if you can
- When dealing with tests that MUST hit the database or SOLR or Sphinx or (OLAP Cubes for those in a Enterprise-y environment) outside of the application code, categorize them somehow to separate them from the faster running tests so you can run them at night or every hour while running your main test suite in seconds
View tests:
- I hate view tests
- But I do them with rSpec
Labels: rails testing rspec


