using phpunit command line arguments in my tests/bootstrap/setup/etc
I want to be able to print some 开发者_开发百科config data to stdout from my tests only when I use the '--verbose' phpunit command line argument.
How can I accomplish this?
Probably this is not really intended by the authors of PHPUnit, but you can do it like this:
<?php
require_once 'PHPUnit/Framework/TestCase.php';
class EnvironmentTest extends PHPUnit_Framework_TestCase
{
public function testHasParam()
{
if (in_array('--verbose', $_SERVER['argv']))
echo "lots of info";
else
echo "no info";
}
}
?>
精彩评论