我是使用codeception的新手,我尝试做一个简单的测试:登录并检查里面的链接。
我在验收测试中使用$I = new AcceptanceTester($scenario);
,但我看到有人使用WebGuy($scenario)
而我不知道WebGuy和AcceptanceTester之间的区别。
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');
[...]
?>
结果(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
当我使用$I = new WebGuy($scenario);
时,我得到了这个:
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
在C:\ xampp \ htdocs \ public_html \ codeception \ tests \ acceptance \ SigninCept.php:3
I have **WebGuy.php in my acceptance dir.**
如果我构建,我会得到这个:
C:\xampp\htdocs\public_html\codeception>php codecept.phar build acceptance --steps
[RuntimeException]
Too many arguments.
build [-c|--config[="..."]]
答案 0 :(得分:1)
“guy”的名称取决于您在套件的代码配置中所拥有的内容(在您的情况下是接受套件):
# acceptance.suite.yml
class_name: AcceptanceTester
modules:
enabled:
- WebDriver
...
当运行codecept build
时,将创建集成类,集成您已定义的模块的所有方法,然后在运行测试时由CodeCeption使用。任何其他类都将被忽略。
另请参阅构建命令的帮助(codecept help build
)以查看可以传递给它的选项(即通常您不需要任何选项)。
答案 1 :(得分:1)
Codeception 2.x仅使用AcceptanceTester。
据说,Guys更名为Testers。演员班和 帮助者由套房命名。例如,验收测试将开始 用这一行:
<?php
$I = new AcceptanceTester($scenario);
// and uses AcceptanceHelper
?>
见这里:http://codeception.com/06-06-2014/codeception-2.0-final.html
答案 2 :(得分:0)
WebGuy
类只是从AcceptanceTester
类扩展的自定义类。您可以实现自己的,并从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:
希望这有助于您理解:)