PHPUnit filenaming约定

J.D*_*ald 3 php phpunit unit-testing

我刚刚开始在一些现有代码上试用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
Run Code Online (Sandbox Code Playgroud)

Ken*_*ric 7

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

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

也,

phpunit --skeleton-test MyClass  MyClass.class.php
Run Code Online (Sandbox Code Playgroud)

可能做你想要的.

   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.
Run Code Online (Sandbox Code Playgroud)

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