【问题标题】:How to use Codeception Acceptance Helper?如何使用 Codeception Acceptance Helper?
【发布时间】:2017-01-16 17:45:47
【问题描述】:

我正在尝试在我的 Cest 类中的所有测试之前登录到 Joomla 后端。

我为此使用了 Joomla 浏览器模块: https://github.com/joomla-projects/joomla-browser

在 cest 类中使用它时,会在每次测试之前执行登录,这是不需要的:

public function _before(AcceptanceTester $I)
{
    $I->doAdministratorLogin();    
}

当像这样将它添加到 Acceptance Helper 时:

namespace Helper;

class Acceptance extends \Codeception\Module
{
    public function _beforeSuite($settings = array()) {
        $I = $this;
        $I->doAdministratorLogin();    
    }
}

我明白了

调用未定义的方法 Helper\Acceptance::doAdministratorLogin()

【问题讨论】:

    标签: php testing joomla codeception


    【解决方案1】:

    您必须检索 JoomlaBrowser 模块:

    $this->getModule('JoomlaBrowser')->doAdministratorLogin();
    

    您还在 Cest 文件中使用了 _before 方法,但在 Helper 文件中使用了 _beforeSuite
    WebDriver 对象未在 _beforeSuite 中初始化。

    您的选择是:

    1. 将该代码移至_before
    2. _beforeSuite中调用_initialize方法

      $this->getModule('JoomlaBrowser')->_initialize(); $this->getModule('JoomlaBrowser')->doAdministratorLogin();

    【讨论】:

    • 我知道[Symfony\Component\Debug\Exception\FatalThrowableError] Call to a member function get() on null
    • 请使用 -vvv 标志运行 codeception 并向我们显示堆栈跟踪。
    • webDriver 尚未在 _beforeSuite 方法中初始化。将该代码移至_before
    • 我应该把什么搬到哪里??
    • 也许您可以将其添加到您的答案中?
    猜你喜欢
    • 2017-09-06
    • 1970-01-01
    • 1970-01-01
    • 2013-09-19
    • 1970-01-01
    • 2020-10-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多