我正在尝试运行Cest格式的验收测试并得到我不理解的错误。任何帮助表示赞赏
捕获致命错误:参数1传递给Codeception \ Module :: __ construct()必须是Codeception \ Lib \ ModuleContainer的一个实例, null给定,在第13行的C:\ CodeCeption \ branches \ suites_hydra \ tests_support \ CcHelper.php中调用,并在C:\ CodeCeption \ bran中定义 第52行的ches \ suites_hydra \ vendor \ codeception \ codeception \ src \ Codeception \ Module.php
这是我的第一个文件
<?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);
}
}
答案 0 :(得分:0)
您的问题出在CcHelper课程中
可能它是为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);
}