当我尝试运行Cest测试时,我收到错误:
Codeception PHP Testing Framework v2.2.6
Powered by PHPUnit 5.6.2 by Sebastian Bergmann and contributors.
PHP Catchable fatal error:
Argument 1 passed to
CartFlowDeliverPointCest::cartFlowDeliverPointCest() must be an
instance of AcceptanceTester, none given, called in
phar:///usr/local/bin/codecept/src/Codeception/Test/Loader/Cest.php on line 37
and defined in /home/michal/www/tests/acceptance/CartFlowDeliverPointCest.php on line 20
我的第一代码:
use \AcceptanceTester;
class CartFlowDeliverPointCest
{
public function cartFlowDeliverPointCest(AcceptanceTester $I)
{
$homePage = new \Page\HomePage($I);
$productNanme = 'Fotoksiążka jesień';
$homePage -> fillSearchField($productName);
$homePage -> clickSearchBtn();
$searchPage -> clickFirstProduct();
$productPage ->clickMakeProductBtn();
}
}
和我的Page Object代码:
<?php
namespace Page;
class HomePage
{
public static $URL = '/';
public static $searchField = ['id' => 'microsearch_fraza'];
public static $searchBtn = "//div[@id='microsearch_fraza_container']/button";
protected $tester;
public function __construct(\AcceptanceTester $I)
{
$this->tester = $I;
}
public static function fillSearchField($productName)
{
$I = $this->tester;
$I->fillField(self::$searchField, $productName);
}
public static function clickSearchBtn()
{
$I = $this->tester;
$I->click(self::$searchBtn);
}
}
My Codeception版本:2.2.6
答案 0 :(得分:1)
我认为你的错误是班级名称和方法名称相同,
所以PHP使用cartFlowDeliverPointCest
方法作为构造函数。
答案 1 :(得分:0)
是否缺少某些代码?您似乎在搜索页面和产品页面上调用方法,而无需先按照主页的方式建立方法。不应该导致这个特定的错误,但一旦你解决了这个问题肯定会成为一个问题。