Setup and run unit testing in PHPUnit with Codeigniter using command line
How to run PHPUnit using command line.
In fact, you can install PHP on Ubuntu Linux via command line by typing a command:
sudo apt-get install php5-cli
After finish download and install the PHP, PHPUnit, and Codeigniter.
Just open up the CIPHPUnit, you will see something like..
In order to setup the project, copy the tests folder from CIPHPUnit and paste into your Codeigniter/application.
The additional detail in setting up PHPUnit with Codeigniter is written in the topic of How to setup and run unit testing in PHPUnit with Codeigniter.
Then create some test cases. if you don’t know how to implement the test, please catch up my topic on How to implement unit testing Controller in PHPUnit with Codeigniter.
Yep, everything is all set!
So… Let’s get start it.
Run the test
Step 1: Open your terminal or cmd, and cd into your Codeigniter project.
Step 2: type the following command and hit enter.
$ cd application/tests/
Step 3: enter this command to run the tests.
$ phpunit --verbose
P.S. --verbose used to show more information. If you don’t want to get the information, you can enter only phpunit.
The result will contain the number of the test and the test results.
Please let me know if you have any questions.