Nice~ 成功跑通~
后,用phpunit.xml定义测试套,跑起来更便捷~
老是敲那么一长串的命令也挺麻烦的,要是能像make一样只要敲一个make搞定好了 —— phpunit刚好提供了一个phpunit.xml让我们能定义常用的测试套之类的选项。
详细的介绍在官方文档中已经很详细了,我这里不?嗦了。只秀个我认为较为简洁有效的配置:
<?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>
把上述内容写入phpunit.xml中后,跑phpunit变得非常简单了,一个phpunit搞定了:
Well done. 收工~