美文网首页
PHPunit-单元测试-环境配置

PHPunit-单元测试-环境配置

作者: MrBryan | 来源:发表于2020-11-04 18:03 被阅读0次
    $ wget http://phar.phpunit.cn/phpunit-6.2.phar
    $ chmod +x phpunit-*.phar
    $ sudo mv phpunit-*.phar /usr/local/bin/phpunit
    $ phpunit --version
    

    /usr/bin/env: php: No such file or directory
    需要配置php环境

    $ vi ~/.bash_profile
    PATH=$PATH:{$phpPath}/php/bin
    export PATH
    $ source ~/.bash_profile
    $ php -version
    PHP 7.0.33 (cli) (built: Aug 19 2019 18:13:42) ( ZTS )
    Copyright (c) 1997-2017 The PHP Group
    Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
        with Zend OPcache v7.0.33, Copyright (c) 1999-2017, by Zend Technologies
     
    $  phpunit --version
    PHPUnit 6.5.3 by Sebastian Bergmann and contributors
    

    请检查是否正确安装xdebug

    $ php -i | grep xdebug
    

    没有安装需要配置

        vi {$phpPath}/php/etc/php.ini
    
    zend_extension="{$path}/xdebug.so"
    xdebug.remote_enable = 1
    xdebug.remote_connect_back = 1
    xdebug.remote_port = 9000
    xdebug.max_nesting_level = 500
    

    phpunit --coverage-html ./{reportsPath}/reports --whitelist ./{codePath}/Hello.php 开启web服务 cd ./{$reportsPath}/reports

    $ php -S 0.0.0.0:8899

    浏览器打开 http://{$hostname-i}:8899

    参考资料
    PHPUnit文档-官方文档

    相关文章

      网友评论

          本文标题:PHPunit-单元测试-环境配置

          本文链接:https://www.haomeiwen.com/subject/akogvktx.html