phpunit代码覆盖功能coverage

1 phpunit中coverage

phpunit中coverage能够很方便的帮助我们查看自己代码覆盖的情况。

Code Coverage Options:

–coverage-clover Generate code coverage report in Clover XML format.
–coverage-crap4j Generate code coverage report in Crap4J XML format.
–coverage-html

Generate code coverage report in HTML format.
–coverage-php Export PHP_CodeCoverage object to file.
–coverage-text= Generate code coverage report in text format.
Default: Standard output.
–coverage-xml Generate code coverage report in PHPUnit XML format.

输出到html

a 配置nginx

$ sudo vim /Data/apps/nginx/conf/nginx-web.conf
server { 
    listen       8080; 
    server_name  phpunit.tt; 
    root    /home/dev/svn/avatar/phpunit; 
    index  index.html index.htm index.php; 
    location ~ \.php$ { 
        include fastcgi_params; 
        fastcgi_pass 127.0.0.1:9000; 
        #fastcgi_param SCRIPT_FILENAME  $documentroot$fastcgi_script_name; 
        fastcgi_index index.php; 
        include fastcgi.conf; 
    } 
}

b) 跑用例
跑全部用例

$ phpunit --coverage-html /home/dev/svn/avatar/phpunit /home/dev/svn/avatar/trunk/services/outpatient/test/all.php

跑一个类里面一个用例

$ phpunit --filter 'CommunityAdminUserSvcTest::testCreate' --coverage-html /home/dev/svn/avatar/phpunit all.php

c)重启Nginx
d)访问 http://10.1.20.101:8080/

你可能感兴趣的:(phpunit代码覆盖功能coverage)