How to link PHPUnit with my code?

I would like to:

  • Run tests using PHPUnit regardless of my environment (and if PHPUnit or PEAR is installed or not)
  • Show test results on screen, if possible

How can i do this? I tried to download the code here and including Autoload.php, but it still has some dependencies. Maybe it’s better for this than trying to associate it with my code ...?

+5
source share
3 answers

To include PHPUnit in the project source files, I suggest following the guide:

Using PHPUnit From a Git Checkout from the PHPUnit Contributung section.

, , , , runner/wrapper script phpunit.

#!/bin/bash
php -d include_path='.:../phpunit/:../dbunit/:../php-code-coverage/:../php-file-iterator/:../php-invoker/:../php-text-template/:../php-timer:../php-token-stream:../phpunit-mock-objects/:../phpunit-selenium/:../phpunit-story/:/usr/local/lib/php' ../phpunit/phpunit.php $*

, script, phpunit

require '/path/to/phpunit/PHPUnit/Autoload.php';
PHPUnit_TextUI_Command::main();

, phpunit.xml.dist cli script.


git, . script :)


SO:

PHP - PHPUnit?

PHPUNIT

+2

, , PHPUnit . PHP ( , ), . sibling APPLICATION_ROOT , "test", "lib" , PHPUnit, , , , . .

, , , , . , -, , PHP, Front Controller , , , . , , , ( .. ).

+1

PHP - http://getComposer.org. PHPunit , http://packagist.org/packages/phpunit/phpunit

With the software installed, it will place the phpunit script command line in the local directory "bin /", so you can call it, although you most likely want to have a shell script that also sets the configuration the file will be used.

The usual setup is a subdirectory of tests / with a hierarchy of classes extending PHPunit that run the actual tests.

+1
source

All Articles