How should I write functional tests for Yii web application that will be run on selenium server? How should I write functional tests for Yii web application that will be run on selenium server? selenium selenium

How should I write functional tests for Yii web application that will be run on selenium server?


there is an easy way to write functional tests.you can downlaod an addon for selenium IDE and then add the php formatter for this addon, and you can make and export functional tests very eeeasy.

then you should configure your protected/config/test.php and protected/tests/bootstrap.php

you should probably edit protected/tests/phpunit.xml and remove any browser, other than fire fox.

then do like Willem Renzema said and change the test made by this addon and change the name of the class to WebTestCase and remove the setUp()

then you are ready to run tests!

cheers


The two packages that are well integrated with Yii, is PhPUnit and Selenium Remote Control. So these two are more common between Yii developers.

Regarding, deploying functional test, I'm not sure how deep you want to go, but as far as I used it, it was pretty easy. Functional tests, are literally php classes, which are extended from CWebTestCase. Yii CWebTestCase class description

Naming convention is you have to name you class ending with Test like ExampleTest.php, and store the files under protected/tests/functional. You need to set up everything including, both packages and also changing Yii configuration file and your default browser. If everything goes well, a sample test can be like this:

class ExampleTest extends WebTestCase{public function testContact(){    $this->open('?r=site/contact');    $this->assertTextPresent('A string on contact page');    $this->assertElementPresent('name=ContactForm[name]');    $this->type('name=ContactForm[name]','tester');    $this->type('name=ContactForm[email]','tester@example.com');    $this->type('name=ContactForm[subject]','test subject');    $this->click("//input[@value='Submit']");    $this->waitForTextPresent('Body cannot be blank.');}}

That's all I knew about it and I hope it helped.