Unit Testing a Website


I'm curious to see how other developers go about testing their web sites. PHP specifically in my case, but this probably spans multiple languages. I've been working on a site for over a year now, and I'd really like to automate a lot of the regression testing I do between versions.

This specific site is in CodeIgniter, so I have some tests for my models. I'd like to move beyond just testing those though. However, this is an issue even non-MVC developers have had to tackle I'm sure.

Edit: I think the functionality that would satisfy a lot of my test desires is the ability to assert that paramters have a specific value at the end of the script processing. In my case a lot of logic is in the controller, and that's the main area I'd like to test.

12/31/2011 6:11:11 AM

Accepted Answer

For actual unit testing without testing the UI, you should just test the functions in the model. Most of your functionality should be in there anyways.

You might want to have a look at Selenium for testing the UI of your site. It can record your actions and play them back, or you can edit the scripting directly. alt text
(source: seleniumhq.org)

3/2/2019 2:00:25 AM

Have you tried Fitnesse ?

It helps on creating Acceptance tests. They are specially useful for websites, which doing this kind of tests are a pain.

There are a couple of videos from unclebob inside the webpage too. The good thing is that Fitnesse is not restricted for website testing, so your knowledge about using it can be used with other apps too.

The project I'm working on is a Desktop APP written in c++ that uses Fitnesse tests.

But if you meant unit testing the models (which I think you didn't), they can be create using the phpunit lib. I think the ZEND framework has a similar lib for that.

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow