教你一步一步寫一個phpunit testcase(16)

發表于:2017-06-01來源:葉左左作者:葉左左點擊數: 標簽:PHPUnit
filter whitelist processUncoveredFilesFromWhitelist = true directory suffix = .php ../src / directory / whitelist / filter / phpunit 加入bootstrap和filter屬性。 執行測試,如果XML名字不是
> <filter> <whitelist processUncoveredFilesFromWhitelist="true"> <directory suffix=".php">../src</directory> </whitelist> </filter> </phpunit>

加入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

Code Coverage 分析

寫好單元測試之后,該如何了解到哪些程序還沒有經過測試?目標程序被測試百分比有多少?

原文轉自:http://www.jianshu.com/p/ba6829a6f3ec

国产97人人超碰caoprom_尤物国产在线一区手机播放_精品国产一区二区三_色天使久久综合给合久久97