Nice~ 成功跑通~
后,用phpunit.xml定義測(cè)試套,跑起來更便捷~
老是敲那么一長(zhǎng)串的命令也挺麻煩的,要是能像make一樣只要敲一個(gè)make搞定好了 —— phpunit剛好提供了一個(gè)phpunit.xml讓我們能定義常用的測(cè)試套之類的選項(xiàng)。
詳細(xì)的介紹在官方文檔中已經(jīng)很詳細(xì)了,我這里不?嗦了。只秀個(gè)我認(rèn)為較為簡(jiǎn)潔有效的配置:
<?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變得非常簡(jiǎn)單了,一個(gè)phpunit搞定了:
Well done. 收工~