无法使用步骤对象执行功能测试

时间:2015-09-18 06:31:14

标签: php codeception

我刚开始在跨代码的功能测试中使用步骤对象。 下面的代码是我的Step对象文件的功能测试用例。

<?php
    class UserCest
    {
        function showUserProfile(\Step\Acceptance\Admin $I)
        {
            $I->loginAsAdmin();
            $I->amOnPage('/admin/profile');
            $I->see('Admin Profile', 'h1');
        }
    }
?>

Step对象文件是

<?php
namespace Step\Acceptance;

class Admin extends \AcceptanceTester
{
    public function loginAsAdmin()
    {
        $I = $this;
        $I->amOnPage('/Drupal 8 Console');
        $I->fillField('#user-login-form input[name=name]', 'qatest');
        $I->fillField('#user-login-form input[name=pass]', 'qatest');
        $I->click('Log in');
    }
}

执行测试用例错误消息时显示为:

Show user profile (UserCest::showUserProfile)
Scenario:
* I am on page "/Drupal 8 Console"
ERROR
-----------------------------------------------------------------------------
Time: 302 ms, Memory: 9.25Mb
There was 1 error:
---------
1) Failed to show user profile in UserCest::showUserProfile
(tests/functional/UserCest.php)
  [RuntimeException] Action 'amOnPage' can't be called

Scenario Steps:
 1. $I->amOnPage("/Drupal 8 Console")

#1  /root/tests/_support/_generated/AcceptanceTesterActions.php:173
#2  /root/tests/_support/Step/Acceptance/Admin.php:9
#3  /root/tests/functional/UserCest.php:6
#4  UserCest->showUserProfile
#5  /root/codecept.phar:7
FAILURES!
Tests: 1, Assertions: 0, Errors: 1.

任何人都可以向我提出解决方案 我们如何“将步骤对象文件导入Cest格式”。

0 个答案:

没有答案