Codeception\Util\Autoload
通过class后缀自动加载class,提供的方法有
public static load($class)
public static matches($class, $namespace, $suffix)
public static register($namespace, $suffix, $path)
public static registerSuffix($suffix, $path)
如
\Codeception\Util\Autoload::registerSuffix('Page', __DIR__.DIRECTORY_SEPARATOR.'_pages');
Console
GenerateSuite:要求的参数有:suite的名称+actor名称
<pre name="code" class="php">php codecept.phar <span style="font-family: Arial, Helvetica, sans-serif;">g:suite api -> api + ApiTester</span>
php codecept.phar <span style="font-family: Arial, Helvetica, sans-serif;">g:suite integration Code -> integration + CodeTester</span>
php codecept.phar <span style="font-family: Arial, Helvetica, sans-serif;">g:suite frontend Front -> frontend + FrontTester</span>
Console:在执行时执行测试命令
php codecept.phar console acceptance
GenerateGroup:php codecept.phar g:group AdminGenerateCept:生成Cept文件
php codecept.phar generate:cept suite Login
php codecept.phar g:cept suite subdir/subdir/testnameCept.php
php codecept.phar g:cept suite LoginCept -c path/to/project
SelfUpdate:自动更新
php codecept.phar self-update
GenerateTest:生成单元测试
php codecept.phar g:test unit User
php codecept.phar g:test unit "App\User"
Build:依据suite.yml文件生成actor类
php codecept.phar build
php codecept.phar build path/to/project
GenerateHelper:生成空的Helper类
Bootstrap:生成默认的config,文件夹等
GeneratePhpUnit:生成GeneratePhpUnit testcase
codecept g:phpunit unit UserTest
codecept g:phpunit unit User
codecept g:phpunit unit "App\User
GenerateScenarios:为testcase生成文本场景
codecept g:scenarios acceptance - for all acceptance tests
codecept g:scenarios acceptance --format html - in html format
codecept g:scenarios acceptance --path doc - generate scenarios to doc dir
GenerateStepObject:生成stepobject类
codecept g:step acceptance AdminSteps
codecept g:step acceptance UserSteps --silent - skip action questions
Clean:清除log
codecept clean
codecept clean -c path/to/project
GenerateCest:生成测试类文件
codecept generate:cest suite Login
codecept g:cest suite subdir/subdir/testnameCest.php
codecept g:cest suite LoginCest -c path/to/project
codecept g:cest "App\Login"
GeneratePageObject:生成page类
codecept g:page Login
codecept g:page Registration
codecept g:page acceptance Login
Configuration
...
Codeception\Util\Fixtures
用于存储数据,应用于Cests/Tests
Fixtures::add('user1', ['name' => 'davert']);
Fixtures::get('user1');
可以用的方法有
public static add($name, $data)
public static cleanup()
public static get($name)
提供一些常用的方法
codecept_debug($data)
codecept_output_dir()
codecept_root_dir()
codecept_data_dir()
Codeception\Util\Locator
为CSS 和 XPath locators提供一些方法
combine:public static combine($selector1, $selector2)
<?php
use \Codeception\Util\Locator;
//下面这句将在h1,h2,h3这三种tag中搜索文本“Title”
$I->see('Title', Locator::combine('h1','h2','h3'));
?>
也可以这样用:
<?php
use \Codeception\Util\Locator;
$I->fillField(Locator::combine('form input[type=text]','//form/textarea[2]'), 'qwerty');
?>
find: 通过元素属性来查找元素
public static find($element, array $attributes)
href:用给定的url来匹配一个元素 public static href($url)
<?php
use \Codeception\Util\Locator;
$I->see('Log In', Locator::href('/login.php'));
?>
iscss:
public static isCSS($selector)
isID:检查元素定位是不是通过ID来实现的 public static isID($id)
isXpath:判断元素定位是不是xpath public static isXPath($locator)
option:匹配一个option元素 public static option($value)
tabIndex:通过tabindex匹配元素 public static tabIndex($index)
Codeception\Util\Stub
...
Codeception\Util\XmlBuilder
...