Topic: What Should I be Testing?

I've fallen in love with TDD. As a PHP developer it's something that I never really did before.  With Rails making it so simple and with the benefits of TDD I've been tring to write more tests and make better use of them as I go.

I find myself writing some tests that seem like they're testing the foundations of rails more than anything.

def test_create
  example = => "Example")

This seems like a waste of time since I'm not really worried that active record is going to die and somehow mess this up.

On the other hand testing validations seems like it might make sense, but again, do I really need to ensure that Rails is going to pay attention to the validations?

There is something to be said for using tests to ensure that things work as expected, which seems to me like testing specific business logic is the main thing that you should be testing.

def test_discount_cannot_make_price_zero
  ten_dollar_book = Book.find(1) = -15

What are the types of things you're testing in your Rails applications? Should I be worried about writing tests that basically ensure ActiveRecord is working as expected? Is that just good general practice or should I focus more of my testing time on business logic?

Re: What Should I be Testing?

There are a few important things I ask myself before adding a test.

- Is it already covered in another test, perhaps at a higher or lower level?
- Will breaking this test actually break the application?
- Is the test much more complicated than the implementation?


Railscasts - Free Ruby on Rails Screencasts

Re: What Should I be Testing?

Thanks for the reply.  As I've been going I think I have slowly been coming to similar conclusions.  A lot of my tests are like those in the testing tutorials where they do test things like validations and activerecord functionality for the sake of explaining how to do so.

None of my application that I've been building as a "get my feet wet" type thing have much complicated business logic or anything really extensive in the models, but I'm sure that as time goes on I will be revisiting those tests.