Codeception - Acceptance tests work but Functional

2019-06-17 01:47发布

I am running the latest version of Codeception on a WAMP platform - My acceptance is very basic however works fine (see below):

$I = new WebGuy($scenario);
$I->wantTo('Log in to the website');
$I->amOnPage('/auth/login');
$I->fillField('identity','admin@admin.com');
$I->fillField('password','password');
$I->click('Login');

In a nutshell - it checks the page is 'auth/login' fills out 2 form fields and clicks the login button. This works without any problems.

Here is my identical functional test:

$I = new TestGuy($scenario);
$I->wantTo('perform actions and see result');
$I->amOnPage('/auth/login');
$I->fillField('identity','admin@admin.com');
$I->fillField('password','password');
$I->click('Login');

When I run this from the command line I get the following error (not the full error but enough to understand the problem):

1) Couldn't <-[35;1mperform actions and see result<-
[0m in <-[37;1LoginCept.php<-[0m <-41;37mRuntimeException: 
Call to undefined method TestGuy::amOnPage<-[0m.......

My Acceptance suite has 'PhpBrowser' & 'WebHelper' modules enabled, the Functional suite has 'FileSystem' & 'TestHelper' enabled (within the acceptance.suite.yml & functional.suite.yml files)

Obviously the amOnPage() function is the problem - however I am led to believe amOnPage() should work in acceptance and functional test? Or I am wrong - also - can someone explain what the numbers mean e.g '<-[35;1m' that appear

UPDATE: I tried adding the 'WebHelper' module to the functional.suite.yml but I do not see the amOnPage() being auto-generated in the TestGuy.php file - any ideas?

My config files are below:

WebGuy

class_name: WebGuy
modules:
enabled:
    - PhpBrowser
    - WebHelper
config:
    PhpBrowser:
        url: 'http://v3.localhost/'

TestGuy

class_name: TestGuy
modules:
enabled: [Filesystem, TestHelper, WebHelper]

2条回答
爷的心禁止访问
2楼-- · 2019-06-17 02:27

Well, this is so, because of TestGuy don't have those methods. All of those methods are in the PhpBrowser, Selenium2 modules or other that inherits from Codeception Mink implementation. So you need to add PhpBrowser in your functional suite in modules section, and then run codecept build command.

Also note that it is better to use Selenium2 module for acceptance test and PhpBrowser for functional tests. The main idea is that acceptance(Selenium2) tests must cover those part of your application, that can not be covered by functional (PhpBrowser) tests, for example some js-interactions.

查看更多
走好不送
3楼-- · 2019-06-17 02:43

About '<-[35;1m' start script codecept run --no-colors to remove '<-[35;1m' from console output

查看更多
登录 后发表回答