加入bootstrap和filter屬性。
執行測試,如果XML名字不是phpunit.xml的話,可以利用--configuration來指定。
直接執行,結果如下:
? how-to-write-a-phpunit-testcase git:(master) ? phpunit tests/EventTest.php
PHPUnit 5.4.8 by Sebastian Bergmann and contributors.
Runtime: PHP 7.0.12 with Xdebug 2.4.0
Configuration: /Users/wangzhihao/git/how-to-write-a-phpunit-testcase/phpunit.xml
..... 5 / 5 (100%)
Time: 101 ms, Memory: 10.00MB
OK (5 tests, 17 assertions)
還有更多的phpunit.xml在這里https://phpunit.de/manual/current/en/appendixes.configuration.html
寫好單元測試之后,該如何了解到哪些程序還沒有經過測試?目標程序被測試百分比有多少?
原文轉自:http://www.jianshu.com/p/ba6829a6f3ec