unit testing - In Ruby on Rails, do you test controllers and views or mostly models? -


I've heard that at the very least, if you only write unit tests for models and keep the bulk of your argument In the model you try, you are very well closed what controllers and ideas or any other part of the structure have the qualifications to test?

I think that is the correct answer - it depends: -)

If your controller is really dumb and contains "one liners" in it, there is no need to check it because nothing (or almost nothing) is broken in it. What you said is your case and remember that you should check the controllers in isolation so that your model is joking and there will be some time / code in it.

Testing views are very complex because you are just thinking to check the layer - then you have to make a duplicate all the models / controllers - this unit is the principle of testing.

So I only voted for the unit testing model. You have almost all the arguments, so your test code coverage is high and writing dead RSPC for the model is simple.

But - apart from the unit test, you should actually go for the integration test. Cucumber is great for that. In the integration tests, you test all the layers at once and not in isolation. And cucumber tests can be discussed with your client because they are human readable. This is really a great source of explanation - when you write an integration test, you may have often found cases with such edges that are not specified (aka "What should the app do if the user clicks there?").

/ Html>

Comments