Tuesday, June 07, 2016
Writing automated tests is important to ensure that the tested features function properly both before and after making future changes to the system.
To prepare to run the Unit Test test suite:
First, install Composer:
vendor/binto your path.
Run all tests, using:
phpunit -c testFramework/unittests/phpunit.xml
While you are debugging a specific test (such as one you're adding, see below), you may want to just call it in isolation rather than running the entire test suite. The syntax for doing this is:
phpunit --filter <test class name> <path to test class file>
phpunit --filter testPaginationCase testFramework/unittests/testsPaginator/paginatorTest.php
To add a new test, create your test in an appropriate subdir under
protected $preserveGlobalState = FALSE; protected $runTestInSeparateProcess = TRUE;
testFramework/unittests, remember to add the new foldername to
Some features can only be properly tested by running them through a browser. We do this using Selenium and Firefox.
Be aware that sometimes the "latest" Firefox may not work with Selenium ... so occasionally may need to use an older Firefox version, or upgrade Selenium to a newer version.
WebTests need to run from a local webserver, so you need a MySQL+Apache/Nginx (or equivalent) setup already present on your computer, and need to be able to access it from your installed Firefox browser. The Zen Cart Habitat server is ideal for this.
Since the webtests will run zc_install, be prepared for your database to be wiped out and your configure.php files to be updated.
testFramework/config/ folder there is a
localconfig_EXAMPLE.php file. Make a copy of that file and configure it to suit your local environment:
localconfig_YOURUSERNAME.php ... ie: if I login to my PC as
bill then the filename would be:
definestatements to reflect your local webserver's domain name, database credentials, etc for your Zen Cart dev site. If you're running in a Zen Cart Habitat environment, the
WEBTEST_ADMIN_PASSWORD_INSTALLshould be set to
a) Start Selenium engine from command line:
java -jar <path_to>/selenium-server-standalone-<version>.jar -trustAllSSLCertificates
b) Start the webtests in another terminal window:
phpunit -c testFramework/webtests/phpunit.xml
Powered by Codex 1.1.0