atlanticbt/selenium-phpunit-framework

There is no license information available for the latest version (v2.0.1) of this package.

This is a Selenium + PHPUnit Framework and test skeleton

v2.0.1 2015-06-20 21:03 UTC

README

=================================================

This is a proof-of-concept black box testing framework + test scaffolding that seeks to integrate PHPUnit and Selenium.

GETTING STARTED

Installation

Composer

Add the following to your repositories (in composer.json)

{
    "type":"composer",
    "url":"http://satis.atlanticbt.com"
}

Add the following dependency (require in composer.json)

"require": {
    "atlanticbt/selenium-phpunit-framework" : "dev-feature/selenium2-test-case-web-driver"
}

NOTE: This value for the release is subject to change, currently dev-feature/selenium2-test-case-web-driver is a beta version geared towards Selenium 2

Download composer.phar in your project

curl -sS https://getcomposer.org/installer | php

Install dependencies

php composer.phar install

Sample Files

The sample files are (semi) optional, depending on your project and project requirements. These instructions assume you have installed the package into the vendor directory of your project root using Composer. If that's not the case, adjust paths accordingly. If you have your own bootstrap file, you'll need to port code that defines the configuration file path.

Bootstrap

  • Copy vendor/atlanticbt/selenium-phpunit-framework/sample/Bootstrap.sample.php into the project root
  • Rename the file to Bootstrap.php
  • Update configurationFilePath to suit your needs, by default assumes your test configs are in the ./tests/config/ directory

PHPUnit

  • Copy vendor/atlanticbt/selenium-phpunit-framework/sample/phpunit.sample.xml into your project root
  • Rename file to phpunit.xml
  • Update appropriately for your project

Tests

  • Copy vendor/atlanticbt/selenium-phpunit-framework/sample/tests directory into your project root
  • Copy (and rename) the files in tests/config, remove the .dist extension
  • Update tests/config/global.php with global configuration (such as site base url)
  • Update /tests/config/test.php with test specific configuration
  • Write your tests, you can use tests/SampleTest.php to start, but eventually you'll want to remove that from your project

MOTIVATION

The goal is to help PHP developers ease into black box (decidedly NOT unit oriented) testing using Selenium + PHPUnit.

Contributors

LICENSE

N/A

DESIGN

  • These testing framework doesn't do much yet, and what it does will need refactoring.
  • Primarily, this abstracts out configuration / setup.
  • Configuration is based on precedence, we have ... ** Global Configuration (shared amongst all tests) in src/tests/config/global.php *** PHP indexed array *** Any file of the format {.}global.php will be read into global config ** Test Configuration (for individual test classes) in src/tests/config/test.php *** PHP indexed array, each class defines a key (i.e. 'login') *** Any file of the format {.}test.php will be read into test-specific config ** PHP GLOBALS *** For instance, as defined by phpunit.xml ** Environment Variables *** For instance, set in test.runner.sh
  • Configuration precedence is (highest to lowest) Environment Variables overwrite GLOBALS overwrite Test Configurations overwrite Global Configurations
  • This setup allows environment specific values so that we can use the test runner to run the tests on different environments (production versus develop server versus local vagrant)

Additional Notes

When you run composer in your project, you will be provided with a sample test runner shell script at /vendor/bin/test.runner.sh The test runner is designed for local testing, such as you want to run the tests on your local machine or within vagrant The PHPUnit sample file can be used to configure the tests in other environments, for instance on Jenkins

Final Thoughts

All typos are intentional