我已尝试在guide
之后使用Yii2基本模板在项目中设置Codeception在我的项目文件夹中,我有3个单元测试 \测试\单元。这是其中之一
<?php
namespace tests\models;
use app\models\User;
class UserTest extends \Codeception\Test\Unit
{
public function testFindUserById()
{
expect_that($user = User::findIdentity(100));
expect($user->username)->equals('admin');
expect_not(User::findIdentity(999));
}
public function testFindUserByAccessToken()
{
expect_that($user = User::findIdentityByAccessToken('100-token'));
expect($user->username)->equals('admin');
expect_not(User::findIdentityByAccessToken('non-existing'));
}
public function testFindUserByUsername()
{
expect_that($user = User::findByUsername('admin'));
expect_not(User::findByUsername('not-admin'));
}
/**
* @depends testFindUserByUsername
*/
public function testValidateUser($user)
{
$user = User::findByUsername('admin');
expect_that($user->validateAuthKey('test100key'));
expect_not($user->validateAuthKey('test102key'));
expect_that($user->validatePassword('admin'));
expect_not($user->validatePassword('123456'));
}
}
按照指南进行到第7步之后,一切都按照指南中的描述完成,但是一旦我尝试运行我的测试,这就是我得到的
codecept run
Codeception PHP Testing Framework v2.3.6
Powered by PHPUnit 5.7.23 by Sebastian Bergmann and contributors.
[1mAcceptance Tests (0) [22m---------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
[1mFunctional Tests (0) [22m---------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
[1mUnit Tests (0) [22m---------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
Time: 520 ms, Memory: 12.25MB
[30;43mNo tests executed![0m