phpstorm集成phpunit

来源:互联网 发布:使命召唤10怎么优化 编辑:程序博客网 时间:2024/06/13 19:37
phpstorm集成phpunit


1.下载phpunit.phar,将该文件放到某个工程中


2.File > Settings > Languages & Frameworks > PHP > PHPUnit
Path to phpunit.phar:选择该工程下的phpunit.phar文件


3.新建文件夹src放源文件,tests放测试文件,在src中新建autoload.php


<?php


function  __autoload($className)
{
    $filePath = "src/{$className}.php";
    if (is_readable($filePath)) {
        require($filePath);
    }
}


4.要生成某个类的测试用例,点类名右键 > Go To > Test > Create New Test ,测试类的路径选择tests


5.新建phpunit运行配置,Test Runner options添 --bootstrap src/autoload.php


6.运行phpunit,如果提示interpreter is not specified,查看File > Settings > Languages & Frameworks > PHP 解释器是否设置
0 1