Codeception Cest Catchable Fatal Error: Argument 1 passed to . . . null given

Codeception Cest Catchable Fatal Error: Argument 1 passed to . . . null given

我正在尝试 运行 一个 Cest 格式的验收测试并得到这个我不明白的错误。任何帮助表示赞赏

Catchable fatal error: Argument 1 passed to Codeception\Module::__construct() must be an instance of Codeception\Lib\ModuleContainer, null given, called in C:\CodeCeption\branches\suites_hydra\tests_support\CcHelper.php on line 13 and defined in C:\CodeCeption\bran ches\suites_hydra\vendor\codeception\codeception\src\Codeception\Module.php on line 52

这是我的 cest 文件

    <?php

    use test\LocatorsPage as Locators;


    class TabCest
{
    protected $Primarycustomer      = "test";
    protected $Virtualcustomer      = "test2";
    protected $Virtualcustomer2     = "test3";
    protected $ccUserName           = "Automation";
    protected $ccPassword           = "pswd";
    protected $accountNumber        = "12345";
    protected $PrimarycustomerId;
    protected $VirtualcustomerId;
    protected $VirtualcustomerId2;


    public function _before(\CcTester $I )
    {
        $this->CcHelper->functiontest(0, array('I' => $I, $this->Primarycustomer, $this-> Virtualcustomer,$this-> Virtualcustomer2));
    }

    protected function _inject(\Codeception\Module\CcHelper $CcHelper, \Codeception\Module\ActionsHelper $ActionsHelper)
    {
        $this->CcHelper = $CcHelper;
        $this->ActionsHelper = $ActionsHelper;
    }

    public function VerifySuccessfulCCLogin (\CcTester $I, $Primarycustomer, $ccUserName, $ccPassword, $accountNumber)
    {

        $I->maximizeWindow();
        $I->amOnPage('/homepage.php');
        $this->ActionsHelper->loginToAA(1, array('I' => $I, 'userName' => $this->$Primarycustomer));
        $I->loginToAA($I, $Primarycustomer, $ccUserName, $ccPassword);
        $I->selectOption(['xpath' => Locators::$cc_searchBy], 'Account Number');
        $I->fillField(['xpath' => Locators::$cc_searchAccNo], $accountNumber);
        $I->click(['xpath' => Locators::$cc_searchBtn]);
        $I->click(['xpath' => Locators::$cc_account_1 . $accountNumber . Locators::$cc_account_2]);
        $I->waitForElement(Locators::$cc_docDetailstab);
    }
}

您的问题出在 CcHelper class.
可能是为 Codeception 2.0 编写的,
Codeception\Module::__construct 的签名在 2.1 中有所不同。

修改 CcHelper::__construct 方法以期望正确的参数并将它们传递给 parent::__construct。

查看 Lumen 模块的简单示例:

public function __construct(ModuleContainer $container, $config = null)
{
    $this->config = array_merge(
        array(
            'cleanup' => true,
            'bootstrap' => 'bootstrap' . DIRECTORY_SEPARATOR . 'app.php',
            'root' => '',
            'packages' => 'workbench',
        ),
        (array) $config
    );
    parent::__construct($container);
}