我在magento测试自动化框架中使用这是我的自定义测试用例。
公共函数test_WithInvalidPassword($errorPasswords,$errorMessage){
//Data
$userData = $this->loadData('generic_admin_user', $wrongPasswords, array('email', 'user_name'));
//Steps
$this->adminUserHelper()->createAdminUser($userData);
//Verifying
$this->assertTrue($this->errorMessage($errorMessage), $this->messages);
$this->assertTrue($this->verifyMessagesCount(), $this->messages);
}
public function data_invalidPassword()
{
return array(
array(array(
'password' => '1234567890',
'password_confirmation' => '1234567890',
), 'invalid_password')
);
}
在这里,它向我显示了类似"SystemStores_CreateTest::test_WithInvalidPassword()"的错误SystemStores_CreateTest::test_WithInvalidPassword()缺少参数1,并且相同的功能在默认的mtaf测试用例中起作用。
有人能建议吗?
您需要设置一个数据提供程序来提供参数的值。
您需要将@dataProvider
注释添加到测试函数的docblock注释中。
您可以在此页面上找到更多信息:ecomdev.org/2011/02/01/hpunit-and-magento-yes-You-can.html,标题为"数据提供商"。
PHPUnit手册中也有一些信息:http://www.phpunit.de/manual/current/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.data-providers.