views:

131

answers:

4

I'm using TOAST and it's doing a great job testing models... but what about views?

A: 

Most likely you don't need to unit test your Views.
If you've got code in your Views that needs unit testing, most likely that code belongs in a related controller/library/etc. Views should mainly just display data it receives from the controller; check for valid data and errors before it gets to the View.

See related post: Unit Testing CodeIgniter with Simpletest

Mitchell McKenna
+2  A: 

If you want to do testing of views, you should concider Unit Testing. PHPUnit is a great one and has a bridge for codeigniter!

http://www.knollet.com/foostack/

Kieran Andrews
+2  A: 

By default there's no possibility to perform unit testing on your views. Codeigniter does has basic unit testing support but in my opinion it lacks many features found in other frameworks (e.g. Rails).

While there are several projects that could solve the problem I doubt they'll work with CI out of the box. As stated by Kieran Andrews you could give PHPUnit a try.

Yorick Peterse
+1  A: 

I would look in to Selenium RC (http://seleniumhq.org/projects/remote-control/) for view testing. It doesn't directly integrate with CodeIgniter. PHPUnit has built in support for it so you may be able to take the driver from there to get it working.

Chris Gutierrez