PHPUnit generated test skeleton path

人盡茶涼 提交于 2019-12-11 00:35:58

问题


Is it possible to tell phpunit where to put generated test skeleton file by the --skeleton-test command? Even is it possible to tell phpunit to repeat directory structure? Lest say i have file for testing in lib/model/SomeClass.php and i want phpstorm to generate unit test class and put it in test/lib/model/SomeClassTest.php without creation of all neccessary directory structure.

Thanks in advance!


回答1:


Example reproduced for convenience

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

Calling the code below should do the trick

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

The arguments (only the first one being mandatory) are

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

as described in the constructor of PHPUnit_Util_Skeleton_Class




回答2:


Yeah that is possible in netbeans IDE. if you configure PHPUnit(Xdebug required) with netbeans then it automatically creates file/folder structure for your framework

Netbeans link

Also it creates the skeleton for each class of Controller and module




回答3:


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

In the constructor change the $outSourceFile to the path you would like the file to save to.

Cheers



来源:https://stackoverflow.com/questions/4409205/phpunit-generated-test-skeleton-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!