Unit testing 基于Yii2的模型单元测试
我正试图通过单元测试来构建Yii2应用程序,对此我有一些疑问Unit testing 基于Yii2的模型单元测试,unit-testing,phpunit,yii2,codeception,Unit Testing,Phpunit,Yii2,Codeception,我正试图通过单元测试来构建Yii2应用程序,对此我有一些疑问 class UsersTest extends \Codeception\TestCase\Test { /** * @var \UnitTester */ protected $users; protected function _before() { $this->users = new \app\models\Users; } protect
class UsersTest extends \Codeception\TestCase\Test
{
/**
* @var \UnitTester
*/
protected $users;
protected function _before()
{
$this->users = new \app\models\Users;
}
protected function _after()
{
}
// tests
public function testGeId()
{
}
}
当我试着运行这个测试类时,我有一条致命的错误消息:找不到Users类。问题的原因是什么?如何解决
Yii2测试文件夹中有自述文件,告诉我们如何设置Yii2 faker和Yii2_basic_测试数据库。这两样东西是什么?我为什么要用它们
谢谢。可能是你
settings:
bootstrap: _bootstrap.php
在codeception.yml中是错误的吗?此文件包括vendor/autoload.php和已解析的类名您可能需要
settings:
bootstrap: _bootstrap.php
在codeception.yml中是错误的吗?该文件包括vendor/autoload.php和已解析的类名在tests/_bootstrap.php中创建应用程序实例时需要用到。该文件中必须包含以下代码:
require('/../vendor/autoload.php');
require('/../vendor/yiisoft/yii2/Yii.php');
$config = require('config/web.php');
(new yii\web\Application($config));
需要在tests/_bootstrap.php中创建应用程序实例。该文件中必须包含以下代码:
require('/../vendor/autoload.php');
require('/../vendor/yiisoft/yii2/Yii.php');
$config = require('config/web.php');
(new yii\web\Application($config));
在phpunit xml配置文件中定义了自动加载程序
在phpunit xml配置文件中定义了自动加载程序
引导是正确的。是的,我的引导文件包括vendor/autoload.php此设置没有很好的文档记录。幸好你贴了这个。引导是正确的。是的,我的引导文件包括vendor/autoload.php此设置没有很好的文档记录。幸好你贴了这个。