介绍 入门 应用结构 请求处理 关键概念 配合数据库工作 接收用户数据 显示数据 安全 缓存 RESTfulWeb服务 开发工具 测试 高级专题 小部件 助手类 其他

发布于 2015-08-01 11:25:24 | 300 次阅读 | 评论: 0 | 来源: 网络整理

Note: This section is under development.

Yii 2 has officially maintained integration with Codeception testing framework that allows you to create the following test types:

  • Unit testing - verifies that a single unit of code is working as expected;
  • Functional testing - verifies scenarios from a user's perspective via browser emulation;
  • Acceptance testing - verifies scenarios from a user's perspective in a browser.

Yii provides ready to use test sets for all three test types in both yii2-basic and yii2-advanced project templates.

In order to run tests you need to install Codeception. You can install it either locally - for particular project only, or globally - for your development machine.

For the local installation use following commands:

composer require "codeception/codeception=2.0.*"
composer require "codeception/specify=*"
composer require "codeception/verify=*"

For the global installation you will need to use global directive:

composer global require "codeception/codeception=2.0.*"
composer global require "codeception/specify=*"
composer global require "codeception/verify=*"

If you've never used Composer for global packages before, run composer global status. It should output:

Changed current directory to <directory>

Then add <directory>/vendor/bin to you PATH environment variable. Now we're able to use codecept from command line globally.

Note: global installation allows you use Codeception for all projects you are working on your development machine and allows running codecept shell command globally without specifying path. However, such approach may be inappropriate, for example, if 2 different projects require different versions of Codeception installed. For the simplicity all shell commands related to the tests running around this guide are written assuming Codeception has been installed globally.

最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务