2012-08-24 97 views
3

我正在使用这是我在magento测试自动化框架中的自定义测试用例。Magento测试自动化框架测试用例创建

公共职能test_WithInvalidPassword($ wrongPasswords,$的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() 缺少参数1 SystemStores_CreateTest :: test_WithInvalidPassword()”并且相同的功能在默认的mtaf-testcases中工作。

任何人都可以为它建议。

回答

1

您需要设置数据提供程序来提供参数的值。

您需要将@dataProvider注释添加到测试功能的docblock注释中。

你可以找到这个页面上的更多信息:标题“数据提供者”下 ecomdev.org/2011/02/01/phpunit-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

+0

你是否应该将数据设置到“data/xyz.yml”文件中? –

+0

您需要将@dataProvider注释添加到测试函数的docblock注释中。您可以在此页面找到更多信息:http://www.ecomdev.org/2011/02/01/phpunit-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。 –

+0

这对我很有帮助..感谢您的帮助。 –