Skip to content

Basic PHPUnit logic and functional tests using selenium and Composer autoload.php, Pear install

Notifications You must be signed in to change notification settings

praveen-garg/phpunit-nerds

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A basic example, which explains basic logic tests and functional tests, using PHPUnit with selenium.

  • Autoloading of classes and namespacing (use: composer install, it will update vendor directory contents for autoloading as per PSR-0)

see instructions below, How to install composer

Note: I have used [latest selenium jar v 2.40.0] (http://selenium-release.storage.googleapis.com/2.40/selenium-server-standalone-2.40.0.jar)

How to run tests:

  • For logic tests:
phpunit --colors tests/Basic/CalculatorTest.php
  • For functional tests (using selenium):
phpunit tests/Basic/CalculatorWebTest.php
  • for all tests, it should be as:
phpunit --colors tests/
PHPUnit 4.0.12 by Sebastian Bergmann.

Configuration read from phpunit.xml

I............

Time: 38.17 seconds, Memory: 4.75Mb

OK, but incomplete, skipped, or risky tests!
Tests: 13, Assertions: 23, Incomplete: 1.

view resides in: src/View/cal.php for which we wrote functional tests.

in phpunit.xml, bootstrap="./vendor/autoload.php" attribute specifies where the bootstrap file is located.

installing composer on MAC

  • Goto a directory & get composer:
curl -sS https://getcomposer.org/installer | php -d detect_unicode=Off
  • move composer into a bin directory you control:
sudo mv composer.phar /usr/local/bin/composer
  • double check composer works
composer about
  • (optional) Update composer:
sudo composer self-update

Troubleshooting

if phpunit tests/Basic/CalculatorWebTest.php output says:

OK, but incomplete or skipped tests!

try

phpunit --verbose tests/Basic/CalculatorWebTest.php

This should tell you the issue(s); 1 of the possible reason may be:

The Selenium Server is not active on host localhost at port 4444.

Make sure to run jar so that selenium server listen (in other terminal tab)

java -jar /usr/local/bin/selenium-server-standalone-2.40.0.jar

TODO:

[Detailed instruction, How to setup PEAR, PHPUnit] (http://www.gargpraveen.blogspot.com/)

and lot more! stay tuned ;)

Thank you!

[Praveen Garg] (http://www.gargpraveen.blogspot.com/)

All used framework/libraries are trademarks of their respective owners. and open source [free licensed to use] to community (as per my knowledge), if any issue please report at: ([email protected]).

The use of these does not indicate endorsement of the trademark holder by nerdapplabs, nor vice versa.

[@nerdapplabs] (http://nerdapplabs.com)

About

Basic PHPUnit logic and functional tests using selenium and Composer autoload.php, Pear install

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages