首先我想问你是否有可能从 PhpStorm 中选定的源类自动生成测试类中的测试模板方法?
例如:
我想为那个类生成测试:
class ReportMyOrdersController extends InitializationController
{
public function init()
{
$this->doSomethingImportant();
}
public function index()
{
$options = [
'option1' => 'surrender',
'option2' => 'fight'
];
return placeOrder('option' . rand(1, 2));
}
public function search()
{
return searchEverywereRightNow('answer');
}
public function doSomethingImportant()
{
return 'somethingImportant';
}
}
应该是这样的:
class ReportMyConversationTest extends \PHPUnit_Framework_TestCase
{
/**
* @test
*/
public function shouldInit()
{
//given
//when
//then
}
/**
* @test
*/
public function shouldIndex()
{
//given
//when
//then
}
/**
* @test
*/
public function shouldSearch()
{
//given
//when
//then
}
/**
* @test
*/
public function shouldDoSomethingImportant()
{
//given
//when
//then
}
}
这可能吗?我正在使用测试驱动开发方法进行编程,这将使我的测试制作变得容易得多。
最佳答案
关于php - 是否可以选择使用我的模板 (PhpStorm) 从源 PHP 类生成测试方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46112631/