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 解释器是否设置

posted @ 2016-08-16 17:49  嘎子哥~  阅读(2684)  评论(0编辑  收藏  举报