有没有办法判断--debug或--verbose是否在测试中传递给PHPUnit?

Gen*_*eck 9 php phpunit

我正在做一些重载到使用CaptureEntirePageScreenshotToString函数的PHPUnit的Selenium扩展,我想只打印截图的路径,因为我们只在传递--verbose或--debug时才去.

例如, phpunit --debug ./tests

然后在我的代码中的某处(这是psudo代码)

if (--debug)
  echo "Screenshot: /path/to/screenshot.png
Run Code Online (Sandbox Code Playgroud)

建议?

edo*_*ian 11

没有PHPUnit内部API来执行此操作.无法通过测试用例直接访问配置对象.

您不能PHPUnit_Util_Configuration::getInstance()仅使用xml配置的包装器.

我的建议是使用:

if(in_array('--debug', $_SERVER['argv'], true)) {
     //Insert your debug code here.
}
Run Code Online (Sandbox Code Playgroud)

相关课程: