-
Notifications
You must be signed in to change notification settings - Fork 1
Acceptance Testing for PHP
This framework for PHP can be used for web acceptance testing of the PHP projects. This framework is build around Behat, Mink, Sauce Labs, ANT. You can configure it continuous integration server like Jenkins.
Now follow these simple steps:
-
Clone Behat Test Automation Framework from GitHub
-
Clone test framework from Github into your local machine.
-
Make sure you have initialized Behat in your root directory, currently its "Behat".
-
Download Seleniumor Sahi and launch Selenium or Sahi server as shown below
You need to download selenium server jar file and execute following command:
$ cd /path/to/selenium-server
$java -jar selenium-server-standalone-2.15.0.jar
Download sahi zip file from SourceForge
Now launch Sahi Server using command below:
$ cd /path/to/sahi
$ cd userdata/bin
$bash start_sahi.sh
You have to launch one of these server before executing 'behat' command. We need to launch server if we wish to run feature locally. We have configured it with these framework if we want to launch it on remote machine using ANT or Jenkins.
Now you are ready to use the framework for adding features and running them with different drivers like Selenium, Sahi or webdriver.
Change "base_url" and "browser" parameters in all config files like 'behat.yml', 'sahi.yml', 'selenium.yml', and 'webdriver.yml' as per your project requirement.
Write sample features for your project. Try to run it locally by using any driver. Remember, you need Selenium, Sahi installed and running before you test feature locally using 'behat' command.
You can run individual feature by using below mwntioned command:
$ cd /path/to/my/project
$behat --name wikiSearch
Requirement:
You need to install Apache Ant on your localhost. You can download and install Ant from Apache Ant.
No need install or download Seleniumor Sahi. It is configured inside this framework. Ant will automatically launch selenium or Sahi server still you need to update version of selenium server frequently. If you like to run it locally, you will need to install Selenium and Sahi.
Now you got three drivers options to run your features
Sahi Driver
Selenium Driver
Selenium 2 Driver (webdriver)
$ cd /path/to/my/project
$ant runSelenium
$ cd /path/to/my/project
$ant runSahi
$ cd /path/to/my/project
$ant runWebdriver
Run feature with Sauce Labs
$ cd /path/to/my/project
$ant sauceTests
You can only run features on Sauce Labs with selenium driver. Sahi driver don't support sauce labs.
If you are using selenium driver then you have to implement wait in your step definitions every time there is new page is loaded like this:
$this->getMink()->getSession()->wait("3000");
Sahi driver waits automatically for element to be appear on page or page to load. You don't have to implement wait if you would like to use Sahi driver.
Once you run 'ant' command from terminal you will see your feature running in browser, you configured.You will see reports generated in "/report" directory. There will be HTML reports as well.
You can configure these ANT tasks on CI server. Specify target "sahiTests" for Sahi driver. Specify target "seleniumTests" for selenium driver Specify target "webdriverTests" for Selenium 2 driver
To generate report, point junit reports to "report/*.xml" It will create reports in Jenkins.