我正在尝试从PHPUnit捕获测试套件的输出,以确定是否发生故障。但是,当我尝试将输出存储在bash变量中时,该变量始终为空:
PHPUNIT_RESULT=`vendor/bin/phpunit`
if [ -z "$PHPUNIT_RESULT" ]; then
echo "something there!
fi
Run Code Online (Sandbox Code Playgroud)
但是,变量似乎总是为空。
编辑:示例输出
PHPUnit 3.4.5 by Sebastian Bergmann.
......F.......F
Time: 0 seconds, Memory: 8.00Mb
There was 1 failure:
1) MyTest::testTemp
Failed asserting that <boolean:false> is true.
/path/to/myTest.php:68
FAILURES!
Tests: 4, Assertions: 5, Failures: 1, Incomplete: 1.
Run Code Online (Sandbox Code Playgroud)
如果有任何测试失败,则phpunit将以非零状态退出。您可以使用$?
变量进行检查。
./vendor/bin/phpunit /path/to/myTest.php
if [ $? -ne 0 ]; then
echo "failed test"
fi
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
671 次 |
最近记录: |