问题
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