加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

PHPUnit filenaming约定

发布时间:2020-12-13 21:34:04 所属栏目:PHP教程 来源:网络整理
导读:我刚刚开始在一些现有代码上试用phpunit.我们使用的命名约定是MyClass类应该在MyClass.class.php中. PHPUnit似乎要求该文件应该被称为MyClass.php. 有没有办法解决? 我在尝试生成骨架测试类时注意到了它: phpunit --skeleton-test MyClass.classPHPUnit 3.
我刚刚开始在一些现有代码上试用phpunit.我们使用的命名约定是MyClass类应该在MyClass.class.php中. PHPUnit似乎要求该文件应该被称为MyClass.php.

有没有办法解决?

我在尝试生成骨架测试类时注意到了它:

phpunit --skeleton-test MyClass.class

PHPUnit 3.3.4 by Sebastian Bergmann.

Could not find class "MyClass.class" in "/home/jd/skeleton/classes/MyClass.class.php".
Fatal error: Call to a member function getOutClassName() on a non-object in /usr/share/php/PHPUnit/TextUI/Command.php on line 470

解决方法

它不是一个要求,它只是假设.您可以编写自己的测试用例.

Skeleton只是模拟一个“简单的方法”,为你的所有类虚拟函数创建虚函数.

也,

phpunit --skeleton-test MyClass  MyClass.class.php

可能做你想要的.

Usage: phpunit [switches] UnitTest [UnitTest.php]
       phpunit [switches] <directory>

--skeleton-class         Generate Unit class for UnitTest in UnitTest.php.
--skeleton-test          Generate UnitTest class for Unit in Unit.php.

所以通过这个推理,如果你不告诉它该类在哪个文件中它将尝试猜测,如果你确实告诉它该类所在的文件,它就不会猜到.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读