Quick links: Content - sections - sub sections
EN FR
The page corresponding to the latest stable release can be seen in the Jelix 1.6 Manual

See the definition of unit-test on wikipedia: https://en.wikipedia.org/wiki/Unit-testing .

Creating tests with PHPUnit

Using PHPUnit to create tests is the prefered method. See the manual of PHPUnit to know how to use it. You must install PHPUnit, it is not provided in the Jelix package.

Jelix brings some helpers. The create-jelix-app command has created a tests/runtests.php in your application (or copy the file lib/jelix-scripts/templates/tests/runtests.php). You will launch this file instead of PHPUnit. It then discover your tests files in all modules. It avoids to not fill a phpunit.xml with all your tests stored in your modules.

To do so:

  • create your tests in the tests/ directory of your modules
  • store them in files with the suffix .pu.php (and not Tests.php as usual with PHPUnit)
  • launch php runtests.php --all-modules to run tests in all modules
  • launch php runtests.php --module foo to run tests only in the module foo
  • you can add the option --testtype xxxx and it launches only *.xxxx.pu.php files. That way, you can separate unit tests, functional tests etc..

You can use all others options of PHPUnit with runtests.php.

Creating tests with Simpletest

This possibility has been removed from the source code of Jelix since Jelix 1.7. You can install the the simpletest-module package via Composer.