3

我正在使用这是我在 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() Missing argument 1 for SystemStores_CreateTest::test_WithInvalidPassword()”的错误,并且相同的功能在默认的 mtaf-testcases 中工作。

任何人都可以建议它。

4

1 回答 1

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 。

于 2012-08-28T02:05:12.193 回答