Page 1 of 1

Running PHPUnit from PHP instead of runner

Posted: Fri Jan 21, 2011 10:46 pm
by jadent
Using PHPUnit 3.6 how to you run a php test suite using PHP instead of the test runner and get output like the test runner?

Re: Running PHPUnit from PHP instead of runner

Posted: Sat Jan 22, 2011 11:13 am
by josh
Do you mean through the web browser? Because the test runner is a PHP script....

Just make file whatever.php

You can use the exec() & passthru() commands to run command line commands, like the PHP test runner, and send it's output to the browser. There's also html based reports PHPunit can dump, as well as phpundercontrol which has it's own reporting styles

Re: Running PHPUnit from PHP instead of runner

Posted: Sat Jan 22, 2011 1:29 pm
by jadent
Thanks but i don't want to run system commands because PHP takes 6 seconds to load.if i run it as a PHP script using the PHPUnit API and then run that through apache then PHP is already loaded and will run immediately.

Running a system command is exactly the same as running on the command line and will take 6 seconds just to load.

You used to be able to run it very easily by getting the result of a test suite and then just doring a $result->toString() or $result->toHtml() but PHPUnit's Framework doesn't provide that so not sure how to get the output easily.

Re: Running PHPUnit from PHP instead of runner

Posted: Sat Jan 22, 2011 1:46 pm
by John Cartwright
jadent wrote:Thanks but i don't want to run system commands because PHP takes 6 seconds to load.if i run it as a PHP script using the PHPUnit API and then run that through apache then PHP is already loaded and will run immediately.

Running a system command is exactly the same as running on the command line and will take 6 seconds just to load.

You used to be able to run it very easily by getting the result of a test suite and then just doring a $result->toString() or $result->toHtml() but PHPUnit's Framework doesn't provide that so not sure how to get the output easily.
Your PHP takes 6 seconds to load? Mine loads immediately from CLI.

Re: Running PHPUnit from PHP instead of runner

Posted: Sat Jan 22, 2011 2:11 pm
by jadent
there are numerous modules that take a while to load. any help on the PHPUnit script?

Re: Running PHPUnit from PHP instead of runner

Posted: Sat Jan 22, 2011 7:24 pm
by josh
PHPunit can take a few moments to analyze all your test files before it begins to execute tests. This hit comes only when running the entire suite at once, when I run only certain tests at once theres much less lag. I have 1,000+ tests with an average of 5 tests per class.

Re: Running PHPUnit from PHP instead of runner

Posted: Sun Jan 23, 2011 7:01 am
by VladSun
If I understand your problem right, you may create a custom php.ini for your CLI tests.
It will load only the necessary modules thus your PHP CLI "loading" will be much faster:

Code: Select all

php -c /path/to/my-simple/php.ini `which phpunit` arguments.....