Hey, I've a application written with a MVC framework it has about 10 forms to insert new data or update existing data. Now every time i extend a feature i have to retest the hole application, and that takes time. how can i automate this? I don't have experience with this unit test thing and as far as i understood the concept its not that useful for me anyway, but maybe I'm wrong. so please adjust your answers to a beginner friendly level :).
Take a look into selenium (seleniumhq.org). There are a whole bucketload of apps that do this kind of thing... this one so happens to be a favorite.
It basically records your keystrokes/click and allows you to replay them. Best of all, it has a firefox extension- which makes this far too easy.
You might be interested by the Selenium suite : basically, it allows one to store tests as an HTML succession of "commands", and run them later in an automated (or semi-automated, as you wish) fashion, in a real browser.
And there is some component bundled in PHPUnit (the most used PHP automated testing framework) to use Selenium -- see Chapter 18. PHPUnit and Selenium
Basically, you generally :
- Record the way you navigate in your application, using the firefox plugin called Selenium IDE
- Then, you often tune that scenario a bit -- generally, to make some stuff more dynamic, for instance
- And, finally, you run the scenarii through Selenium RC (Which is a "remote control" to a real browser), using PHPUnit classes
It allows you to run the same tests again and again, in a real browser -- which means really using your application.
A couple of notes :
- You obviously need a computer on which a browser can be launched (i.e. a testing server with some GUI)
- You sometimes/often have to adapt a bit your HTML templates, to add some
id
, or stuff like that - The static scenarii recorded by Selenium IDE generally need to be made more "dynamic" -- an example being that, because of a UNIQUE constraint in your DB, you can't use the same e-mail address twice to register two different users : the address needs to be dynamic
- Running tests with Selenium takes time : each page has to be loaded in a browser.