php - 是否可以选择使用我的模板 (PhpStorm) 从源 PHP 类生成测试方法

标签 php testing phpstorm

首先我想问你是否有可能从 PhpStorm 中选定的源类自动生成测试类中的测试模板方法?

例如:

我想为那个类生成测试:

class ReportMyOrdersController extends InitializationController
{
    public function init()
    {
        $this->doSomethingImportant();
    }

    public function index()
    {
        $options = [
            'option1' => 'surrender',
            'option2' => 'fight'
        ];

        return placeOrder('option' . rand(1, 2));
    }

    public function search()
    {
        return searchEverywereRightNow('answer');
    }

    public function doSomethingImportant()
    {
        return 'somethingImportant';
    }

}

应该是这样的:

class ReportMyConversationTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @test
     */
    public function shouldInit()
    {
       //given

       //when

       //then
    }

    /**
     * @test
     */
    public function shouldIndex()
    {
       //given

       //when

       //then
    }

    /**
     * @test
     */
    public function shouldSearch()
    {
       //given

       //when

       //then
    }

    /**
     * @test
     */
    public function shouldDoSomethingImportant()
    {
       //given

       //when

       //then
    }
}

这可能吗?我正在使用测试驱动开发方法进行编程,这将使我的测试制作变得容易得多。

最佳答案

关于php - 是否可以选择使用我的模板 (PhpStorm) 从源 PHP 类生成测试方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46112631/

相关文章:

php - 如何禁用和启用mysql中所有表的所有约束

javascript - 很难让 JavaScript XMLHttpRequest 执行任何操作,停止刷新页面

php - php中的日期差异?

testing - 如何避免 npm 中的 "No test specified"错误?

android - 如何在 google play store 的单个轨道中提供 2 个版本?

php - MySQLi bind_param() 错误

ruby-on-rails - 使用 RSpec 进行 Rails 片段缓存测试

javascript - PHPStorm 无法打开 js 文件

PhpStorm没有启动

javascript - Vue 未解析的变量 PhpStorm