- Tests should only be run on a test system, never a live one.
- They have been created to help developers test and improve not only OpenCart but also modules too.
- Install Git (most developers will already have this!)
- Install composer
- Git clone OpenCart (you cannot download the ZIP as this will not include the tests).
- Install OpenCart as normal
- Go to your command line (Windows > Run > Cmd), Shell, or Git Bash
- Change directory to /tests/phpunit/ folder
- Type in the command line: composer update (this will create you a vendor folder and download all dependencies)
- Composer will now pull in all of the required externals/dependencies
- run: vendor\bin\phpunit --bootstrap bootstrap.php opencart\admin to run tests in admin folder
- run: vendor\bin\phpunit --bootstrap bootstrap.php opencart\catalog to run tests in catalog folder
- run: vendor\bin\phpunit --bootstrap bootstrap.php opencart\system to run tests in system folder
Running Acceptance (Functional) Tests with Selenium requires a standalone selenium server on your machine.
The server can be downloaded from here. Before starting your Selenium Tests
you have to run the standalone server: java -jar selenium-server-standalone-2.32.0.jar
. Writing Selenium Tests requires you to extend the OpenCartSeleniumTest class.
- run: vendor\bin\phpunit --bootstrap bootstrap.php selenium\catalog to run tests in system folder
The tests are still under development, there is hundreds of them to do.
The tests will drop and recreate tables in database specified in config.php and admin/config.php
You will also see a build.xml file inside the project root which you can use to configure a Jenkins build.
If you understand testing, then you know how important it is to any project. If you have a suggestion then we would really like to hear it!
Forum thread: http://forum.opencart.com/viewtopic.php?f=177&t=124532
Please help by contributing to writing unit tests and submitting a pull request!