Forum: Ruby on Rails Fragility of View Tests

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jordan M. (Guest)
on 2007-06-02 18:10
I've always used the standard unit/functional/integration tests and
found them satisfying.  I recently started a new project with existing
tests written using ZenTest.  I was surprised to learn about the
controller/view/helper tests it provides.

On one hand I understand the reasoning for breaking down functional
tests into more specific concerns.  It makes sense to test that a
controller is controlling properly and that a view is rendering
properly.

However in practice I'm worried that a view test would be far too
fragile.  What exactly can you test?  That a form shows up or that a
specific h1 tag is present?  Given how quickly agile code changes, is it
really worthwhile to test views to that degree?  If a view renders with
an error, you would still see that fault in a well constructed
functional test.

I also don't like the fact that you need to assign variables before
rendering the view.  Not only does it seem clunky and redundant, you're
liable to miss a problem that stems from the controller.  To really
capture the interaction between a controller and a view, you'd end up
needing to do some integration/functional test anyway.

Is anyone else using view tests?  What do you think of them?  I'm
interested to know if you're doing TDD and if you're working on design
at the same time.

Jordan
http://jordan.mckible.com
This topic is locked and can not be replied to.