Codeception - Acceptance tests work but Functional test don't

Zabs picture Zabs · Jun 14, 2013 · Viewed 7.8k times · Source

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','[email protected]');
$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','[email protected]');
$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]

Answer

user1312885 picture user1312885 · Jun 14, 2013

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.