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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM