简体   繁体   English

WebGuy编码接收

[英]WebGuy codeception

I'm new using codeception and i try to do a simple test: Log in and check links inside. 我是使用Codeception的新手,我尝试做一个简单的测试:登录并检查其中的链接。

I'm using $I = new AcceptanceTester($scenario); 我正在使用$I = new AcceptanceTester($scenario); in my acceptance test but i see people using WebGuy($scenario) and i don't know the difference between WebGuy and AcceptanceTester. 在我的验收测试中,但是我看到人们在使用WebGuy($scenario)我不知道WebGuy和AcceptanceTester之间的区别。

SigninCept.php code: SigninCept.php代码:

<?php 
//webLOG IN
$I = new AcceptanceTester($scenario);
$I->wantTo('Log in my app mobile');
//$I->amOnUrl('192.168.X.X/app/mobile/');
$I->amOnPage('/');
$I->fillField('user','test');
$I->fillField('password','test1234');
$I->fillField('zone','01');
//$I->uncheckOption('input[type=checkbox]');
$I->seeCheckboxIsChecked('#rememberme');
$I->seeElement('input[name=submit]');
$I->click('input[type=submit]');

//succes
$I->wantTo('Check main page');
$I->amOnPage('/principal.php');
$I->seeLink('salir','salir.php');
[...]
?>

Result(cmd): 结果(CMD):

C:\xampp\htdocs\public_html\codeception>php codecept.phar run acceptance --steps

Codeception PHP Testing Framework v2.0.9
Powered by PHPUnit 4.4.0 by Sebastian Bergmann.

Acceptance Tests (1) -----------------------------------------------------------
---------------------------------------
Trying to Log in App Mobile (SigninCept)

Scenario:
* I am on page "/"
* I fill field "user","test"
* I fill field "password","test1234"
* I fill field "zone","01"
* I see checkbox is checked "#rememberme"
* I see element "input[name=submit]"
* I click "input[type=submit]"
* I am on page "/principal.php"
* I see link "salir","salir.php"
[...]
PASSED

When i use $I = new WebGuy($scenario); 当我使用$I = new WebGuy($scenario); i get this: 我得到这个:

C:\xampp\htdocs\public_html\codeception>php codecept.phar run acceptance --steps

Codeception PHP Testing Framework v2.0.9
Powered by PHPUnit 4.4.0 by Sebastian Bergmann.

Acceptance Tests (1) -----------------------------------------------------------
---------------------------------------
Trying to Log in App mobile(SigninCept)

Scenario:

Fatal error: Class 'WebGuy' not found in C:\xampp\htdocs\public_html\codeception\tests\acceptance\SigninCept.php on line 3



FATAL ERROR. TESTS NOT FINISHED.
Class 'WebGuy' not found

in C:\\xampp\\htdocs\\public_html\\codeception\\tests\\acceptance\\SigninCept.php:3 在C:\\ xampp \\ htdocs \\ public_html \\ codeception \\ tests \\ acceptance \\ SigninCept.php:3中

I have **WebGuy.php in my acceptance dir.**

If i do build i get this: 如果我建立,我得到这个:

C:\xampp\htdocs\public_html\codeception>php codecept.phar build acceptance --steps



[RuntimeException]
Too many arguments.



build [-c|--config[="..."]]

The name of the "guy" depends on what you have in codeception configuration of your suite (in your case the acceptance suite): “ guy”的名称取决于您套件(在您的情况下为接受套件)的代码接收配置中所拥有的:

# acceptance.suite.yml
class_name: AcceptanceTester
modules:
    enabled:
        - WebDriver
    ...

When running codecept build the guy class will be created integrating all the methods of the modules you have defined, and it will then used by CodeCeption when running the tests. 当运行codecept build ,将创建一个类类,它集成了您定义的模块的所有方法,然后在运行测试时由CodeCeption使用。 Any other classes will be ignored. 任何其他类都将被忽略。

Also see the help for the build command ( codecept help build ) to see what options you can pass to it (ie normally you don't need any option). 另请参阅build命令的帮助( codecept help build ),以查看可以传递给它的选项(即通常不需要任何选项)。

Codeception 2.x use only AcceptanceTester. Codeception 2.x仅使用AcceptanceTester。

As it was said, Guys were renamed to Testers. 据说,Guys被重命名为Testers。 Actor classes and helpers are named by suite. 演员类和助手按套件命名。 For instance, acceptance test will start with this line: 例如,验收测试将从以下这一行开始:

<?php
$I = new AcceptanceTester($scenario);
// and uses AcceptanceHelper
?>

See here : http://codeception.com/06-06-2014/codeception-2.0-final.html 看到这里: http : //codeception.com/06-06-2014/codeception-2.0-final.html

the WebGuy class is only a custom class that extends from the AcceptanceTester Class. WebGuy类只是从AcceptanceTester类扩展的自定义类。 You can implement your own and call it from the acceptance.suite.yml 您可以实现自己的方法,并从acceptance.suite.yml调用它

class_name: AcceptanceTester ==> or  ==> WebGuy // here is the call of the class
modules:
   enabled: 
      - WebDriver:
         url: 'http://local.symmetryk.com/'
         browser: firefox
         window_size: maximize
         wait: 10
         capabilities:
             unexpectedAlertBehaviour: 'accept'

        env:
        chrome:
         modules:
            config:
                WebDriver:
                    browser: 'chrome'

      - Db:

hope this will help you understand :) 希望这可以帮助您理解:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM