functional, integration and uni tests: when, what?

unit tests test the model/database part of the operation functional tests test a single controller integration tests test any and all controllers simulating a session by one or more users.

I believe that anything done by a functional test could be done by an integration test - I guess that functional tests are slighly simpler and thus better if that is all that is required.

I look forward to being corrected by someone better informed

Hi --

unit tests test the model/database part of the operation functional tests test a single controller integration tests test any and all controllers simulating a session by one or more users.

I believe that anything done by a functional test could be done by an integration test - I guess that functional tests are slighly simpler and thus better if that is all that is required.

At RailsConf Europe, the question came up on the core team panel whether functional tests were in effect obsolete because of integration tests. There was some interesting discussion, and a couple of different perspectives.

I have to admit I write relatively few functional tests. I'm not claiming that's a best practice; I just find myself reaching for integration tests, since they are a superset of functional tests and I have no particular reason to favor the "test one controller at a time" principle as long as I feel I've tested what I need to.

Maybe it's just that I hit a few cases where I had to jump through hoops to run two controllers in a functional test (e.g., to perform a login and then do something else), so I tended to view integration tests as a superior way to do what I was already doing and more.

David

The problem with the Rails 1.2 RC1 is that there are bugs in the API that makes the integration testing very difficult. I have found that unit testing and functional testing helps me to keep moving forward with my project when I am adding features as well as when I am refactoring.

Instead of doing integration testing, for the time being I have decided to use Selenium on Rails as a substitute. When the bugs are fixed I will be doing more integration tests.