Nice~ 成功跑通~
后,用phpunit.xml定義測試套,跑起來更便捷~
老是敲那么一長串的命令也挺麻煩的,要是能像make一樣只要敲一個make搞定好了 —— phpunit剛好提供了一個phpunit.xml讓我們能定義常用的測試套之類的選項。
詳細的介紹在官方文檔中已經(jīng)很詳細了,我這里不?嗦了。只秀個我認為較為簡潔有效的配置:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
backupGlobals = "false"
backupStaticAttributes = "false"
colors = "true"
convertErrorsToExceptions = "true"
convertNoticesToExceptions = "true"
convertWarningsToExceptions = "true"
processIsolation = "false"
stopOnFailure = "false"
syntaxCheck = "false"
bootstrap = "tests/bootstrap.php" >
<testsuites>
<testsuite>
<directory>tests/sample</directory>
</testsuite>
<!-- ... -->
</testsuites>
</phpunit>
把上述內(nèi)容寫入phpunit.xml中后,跑phpunit變得非常簡單了,一個phpunit搞定了:
Well done. 收工~