Topic: testing how the app looks and functions - fixtures for views?

Obviously Rails is amenable to lots of ways of testing the application functionality from automated tests. What I don't see a lot of talk about, however, is tooling for developing and testing the visual design and javascript functionality.

For instance, if you're not really an application designer, and your job is just to make the page design look right, how could you reliably reproduce a page under several different conditions (e.g.: logged in vs. logged out, one item shown vs. multiple, flash message present or not, form validation errors displayed or not, etc.) even just to develop the design, and preferably to have a test suite (e.g. slideshow for designer to look at) of known problem areas to check every time there's a design change? And what about testing your functional Javascript under varying conditions as well?

With model and controller tests, you can build your tests assuming that fixtures have loaded a known state for each test. Is there a way to have a browser load a view that has been provided with its own "fixtures"? Maybe a "fixture" controller? Or is there some other method that satisfies this need and I've just missed it so far in my searching?

Re: testing how the app looks and functions - fixtures for views?

sosiouxme wrote:

What I don't see a lot of talk about, however, is tooling for developing and testing the visual design and javascript functionality.

Cucumber + Webrat? Selenium?

The only way to test the "visual design" is human eye, or you can use some apps that can simulate the rendering in IE, Firefox, Safari and Opera, but it will never be 100% accurate.

Re: testing how the app looks and functions - fixtures for views?

Johnson wrote:

The only way to test the "visual design" is human eye

Yes - but my question is, does anyone have a way for a designer to get the rails app to show views under various different conditions, without having to actually operate the app (which could be quite cumbersome) in order to do it? Thus "fixtures for views."

Re: testing how the app looks and functions - fixtures for views?

Don't use fixtures use a Factory instead: Machinist, Factory girl, Fixture replacement, etc.

We actually use our own homegrown Factory code to generate the data to insert in the DB.

Re: testing how the app looks and functions - fixtures for views?

Maybe I'm missing the point of the question here. Unit and Functional tests provide a path to testing both back-end objects and front end views (error messages, data, etc). Since you can create test fixtures for each test, you can simulate whatever data conditions you need.

Selenium provides a non-programmatic way to develop tests, which can be executed in the browser (or optionally exported into Ruby and run from the command line). While it doesn't have the advantage of fixtures, it does have the advantage of testing from the GUI (via the HTML DOM).

Basically, you've got two paths to testing out the GUI and ensuring that it does what it's supposed to do. If your a page designer, Selenium may be easier to work with since it's basically a FireFox plugin that allows you to "record" your actions and play them back... all the while viewing the results. You could make changes to the design of the page, then run the Selenium test case to get the page into the specific state you want to view.

Thanks!

Last edited by Michael Sullivan (2009-03-04 02:46:40)

"Fools ignore complexity. Pragmatists suffer it. Some can avoid it. Geniuses remove it. " - Alan Perlis