Running tests from the command line

In this recipe, we will learn how to run our unit tests from the command line, which opens the possibility for automated test reporting.

Getting ready

To go through this recipe we need a basic application skeleton to work with, which should have its own set of unit tests. Go through the entire recipe Creating fixtures and testing model methods.

How to do it...

Using your operating system console, switch to your application directory, and run:

If you are on a GNU Linux / Mac / Unix system:

../cake/console/cake testsuite app case models/article

If you are on Microsoft Windows:

..cakeconsolecake.bat testsuite app case models/article

The shell should now run the specified unit test and inform us that all unit tests succeeded, as shown in the next screenshot:

How to do it...

How it works...

CakePHP's testsuite shell allows us to execute any test case, or group of test cases, from the command line. It offers several ways to specify which unit test to execute by specifying a minimum of two arguments.

The first argument can either be app, core, or a plugin name. Use app when intending to execute a unit test, or group of tests, from your application directory. Use core if you wish to run CakePHP's core tests. Finally, if you wish to run tests from a plugin, use the plugin name as the first argument to the testsuite shell.

The second argument should specify what type of unit test to run. It can be set to all, which runs all tests; group, which runs the test group specified in the third argument; or case, which runs the test case defined in the third argument.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.91.24