behat / debug-extension
调试 Behat 场景并将任何信息打印到命令行
1.0
2016-05-09 13:28 UTC
Requires
- php: >=5.5
- behat/behat: >=3.0.6
Requires (Dev)
- phpunit/phpunit: 4 - 5
This package is auto-updated.
Last update: 2024-09-10 21:18:58 UTC
README
在测试套件执行期间将任何信息打印到命令行。
用法
将 @debug
标签添加到您的功能定义中
@debug Feature: Test Scenario: Test # ...
将扩展添加到您的配置文件中
default: extensions: Behat\DebugExtension: ~
通过特质扩展您的对象
use Behat\DebugExtension\Debugger; class Example { use Debugger; }
在任何您想使用的地方使用 debug
方法
public function method() { // ... self::debug([ 'Function arguments: %s', 'Second line', ], [ var_export(func_get_args(), true), ]); // ... }
如您所见,debug
方法通过 sprintf()
函数处理,因此方法的一个参数是一个占位符数组。
消息
此外,使用此扩展,您还可以将样式化的消息打印到命令行。
new \Behat\DebugExtension\Message('comment', 2, [ 'This is a first line of a message that will be printed to a command line.', 'Read documentation for this class to know how to use it.', ]);
程序性使用
export BEHAT_DEBUG=true
这个环境变量告诉消息应该以任何方式打印。