Using phpunit command line arguments in my tests / bootstrap / setup / etc

I want to be able to print some configuration data to stdout from my tests only when I use the phpunit --verbose command line argument.

How can i do this?

+4
source share
1 answer

It may not be intended for PHPUnit authors, but you can do it this way:

<?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"; } } ?> 
+7
source

Source: https://habr.com/ru/post/1338529/


All Articles