问题
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