代码接收-验收测试有效,但功能测试无效 [英] Codeception - Acceptance tests work but Functional test don't

查看:117
本文介绍了代码接收-验收测试有效,但功能测试无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在WAMP平台上运行最新版本的Codeception-我的接受是非常基本的,但是效果很好(请参见下文):

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');

简而言之-它检查页面是否为 auth / login,填写2个表单字段并单击登录按钮。

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.......

我的接受套件具有 PhpBrowser和启用了 WebHelper模块,功能套件具有文件系统和启用 TestHelper(在accept.suite.yml和functional.suite.yml文件中)

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

显然,amOnPage()函数是问题所在,但是我却被引导相信amOnPage()应该在验收和功能测试中起作用?还是我错了-同样-有人可以解释数字的含义吗,例如出现的<-[[35; 1m]

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

更新:我尝试添加 WebHelper模块到functional.suite.yml,但我看不到在TestGuy.php文件中自动生成amOnPage()-有任何想法吗?

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?

我的配置文件是如下:

WebGuy

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

TestGuy

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


推荐答案

是的,是这样的,因为TestGuy没有这些方法。所有这些方法都位于PhpBrowser,Selenium2模块或其他从Codeception Mink实现继承的方法中。因此,您需要在模块部分的功能套件中添加PhpBrowser,然后运行 codecept build 命令。

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.

也请注意,最好将Selenium2模块用于验收测试,而将PhpBrowser用于功能测试。主要思想是验收(Selenium2)测试必须覆盖应用程序的那些部分,而功能(PhpBrowser)测试则不能覆盖这些部分,例如某些js交互。

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.

这篇关于代码接收-验收测试有效,但功能测试无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆