安装Codeception:
composer global status composer global require "codeception/codeception=~2.0.0" "codeception/specify=*" "codeception/verify=*"
安装Faker:
cd /var/www/yii // 您的应用程序路径 composer require --dev yiisoft/yii2-faker:*
创建一个数据库,该数据库将仅用于测试。您可以复制现有数据库或应用迁移:
cd tests codeception/bin/yii migrate
在中调整components['db']配置tests/codeception/config/config-local.php。
将目录添加/var/www/yii/vendor/bin到您的路径。
查看所有配置和.yml文件。
启动Web服务器,例如:
php -S localhost:8080
运行测试:
codecept run
更多信息:
http://www.yiiframework.com/doc-2.0/guide-test-environment-setup.html
http://codeception.com/install
https://github.com/yiisoft/yii2-app-basic/tree/master/tests
https://github.com/yiisoft/yii2-app-advanced/tree/master/tests
注意:这些说明对Yii2 2.0.9版有效。根据Sam Dark的说法,在版本2.0.10中,测试部分将被重构(并且说明必须进行更新)。2.0.10版本应于2016年9月11日发布:https://github.com/yiisoft/yii2/milestones