Testing 为模块yii2创建测试
您好,我是yii2测试新手,我在应用程序/测试中设置了测试环境和测试,并且工作正常。 现在我想为我的一个模块设置测试,它是modules/v1,包含命令、组件、控制器和模型文件夹。 我已经使用Testing 为模块yii2创建测试,testing,yii2,codeception,yii2-basic-app,Testing,Yii2,Codeception,Yii2 Basic App,您好,我是yii2测试新手,我在应用程序/测试中设置了测试环境和测试,并且工作正常。 现在我想为我的一个模块设置测试,它是modules/v1,包含命令、组件、控制器和模型文件夹。 我已经使用codecept bootstrap为modules/v1中的测试创建了初始设置,设置如下 codeception.yml namespace: v1 paths: tests: tests output: tests/_output data: tests/_data su
codecept bootstrap
为modules/v1中的测试创建了初始设置,设置如下
codeception.yml
namespace: v1
paths:
tests: tests
output: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
actor_suffix: Tester
settings:
bootstrap: /../_bootstrap.php
colors: true
memory_limit: 1024M
extensions:
enabled:
- Codeception\Extension\RunFailed
modules:
enabled:
- Yii2:
configFile: '/../../config/test.php'
测试/unit.suite.yml
actor: UnitTester
modules:
enabled:
- Asserts
- \v1\Helper\Unit
actor: FunctionalTester
modules:
enabled:
- Asserts
- \v1\Helper\Functional
测试/functional.suite.yml
actor: UnitTester
modules:
enabled:
- Asserts
- \v1\Helper\Unit
actor: FunctionalTester
modules:
enabled:
- Asserts
- \v1\Helper\Functional
tests/_bootstrap.php
<?php
define('YII_ENV', 'test');
defined('YII_DEBUG') or define('YII_DEBUG', true);
require_once(__DIR__ . '/../../../vendor/yiisoft/yii2/Yii.php');
require __DIR__ .'/../../../vendor/autoload.php';
意味着它没有签入commands/ReportController.php
<?php
namespace app\modules\v1\commands;
class ReportController extends Controller
{
public function actionOverview()
{
echo 1;
}
}
问题。
1-这就是使用单独的测试文件夹测试模块的方式吗?如果是,那么我做错了什么?如果没有,那么正确的方法是什么?
2-如何测试命令(控制台命令)?我将把实现目标的工作留给其他有相同问题的人。
我在中使用了codeception环境 并为控制台和web应用程序设置不同的配置文件。 然后在运行测试时使用--env
codecept运行——环境控制台