【问题标题】:PHPUnit generated test skeleton pathPHPUnit 生成的测试骨架路径
【发布时间】:2010-12-10 13:17:21
【问题描述】:

是否可以通过 --skeleton-test 命令告诉 phpunit 将生成的测试骨架文件放在哪里?甚至可以告诉 phpunit 重复目录结构吗? 以免我在 lib/model/SomeClass.php 中有测试文件,我希望 phpstorm 生成单元测试类并将其放入 test/lib/model/SomeClassTest.php 而不创建所有必需的目录结构。

提前致谢!

【问题讨论】:

  • 看起来没人能回答。
  • 你不能只指定文件的完整路径吗?或者编写 bash 脚本为你添加它?

标签: php unit-testing testing symfony1 phpunit


【解决方案1】:

为方便起见,转载示例

mkdir lib/model tests/lib/model
echo "<?php class SomeClass{}" > lib/model/SomeClass.php

调用下面的代码应该可以解决问题

phpunit --skeleton-test SomeClass library/model/SomeClass.php SomeClassTest tests/library/model/SomeClassTest.php

参数(只有第一个是强制性的)是

$inClassName, 
$inSourceFile = '',
$outClassName = '',
$outSourceFile = ''

PHPUnit_Util_Skeleton_Class的构造函数中所述

【讨论】:

    【解决方案2】:

    是的,这在 netbeans IDE 中是可能的。如果您使用 netbeans 配置 PHPUnit(需要 Xdebug),那么它会自动为您的框架创建文件/文件夹结构

    Netbeans link

    它还为每个控制器和模块类创建骨架

    【讨论】:

      【解决方案3】:

      /vendor/phpunit/phpunit-skeleton-generator/src/TestGenerator.php

      在构造函数中,将 $outSourceFile 更改为您希望文件保存到的路径。

      干杯

      【讨论】:

        猜你喜欢
        • 2014-05-17
        • 1970-01-01
        • 2012-11-16
        • 2012-10-19
        • 1970-01-01
        • 2016-03-09
        • 2012-09-14
        • 2012-11-18
        • 2020-03-05
        相关资源
        最近更新 更多