【发布时间】:2021-09-07 02:31:40
【问题描述】:
我正在尝试使用 Codeception 进行基本的 UnitTest。没有使用任何框架。
我的工作根是:
tests |
|-unit
|-Test.php
includes|
|-general
|-Custom.php
在Custom.php
<?php
namespace Custom;
class General {
public static function check(){}
}
我的测试用例是:
<?php
use Custom\General;
use PHPUnit\Framework\TestCase;
final class Test extends TestCase
{
public function testPushAndPop(): void
{
General::check();
}
}
我的 composer.json 中也有:
"autoload": {
"psr-4":{
"Custom\\":"includes/general"
}
},
当我跑步时
php vendor/bin/codecept run unit
...
1) Test: Push and pop
Test tests/unit/Test.php:testPushAndPop
[Error] Class 'DB\General' not found
#1 /var/www/html/prj/tests/unit/Test.php:9
【问题讨论】:
-
这是自动加载问题,名为
General的类应该存储在General.php中 -
你是对的,但为什么呢? IDE 未声明任何错误...
标签: phpunit codeception