Codeception - Acceptance tests work but Functional test don't

北战南征 提交于 2019-12-08 19:08:48

问题


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]

回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/17106021/codeception-acceptance-tests-work-but-functional-test-dont

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!