Simple check of PHPUnit result

主宰稳场 提交于 2019-12-13 02:35:14

问题


I want to to glue PHPUnit with other command tools and I need a simple way to check if the tests passed or failed.

Somethings like

phpunit path_to_folder_containing_the_test

Would return "ok" if all passed or "failed" if any test failed.

[So I can simply check for "ok" and "failed" values from other tools]


回答1:


I have a very simply shell script that capture the exit code like:

>phpunit TestOk.php
>echo $?
0

and

>phpunit TestKo.php
>echo $?
1

Hope this help




回答2:


In your batch file, look for ERRORLEVEL

@echo off
call PHPUNIT.bat
if ERRORLEVEL 1 goto Fail
if ERRORLEVEL 0 goto Pass
:Pass
echo PHPUnit Successfully Executed
goto End
:Fail
echo PHPUnit Failed
goto End
:End

Change the echo statements to do whatever you wanted. If PHPUnit is returning other error codes (255 and down) then you can continue to use if ERRORLEVEL 255 to control functionality on that specific return code.



来源:https://stackoverflow.com/questions/29164652/simple-check-of-phpunit-result

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!