PHPUnit can#39;t found the quot;TestCasequot; class(PHPUnit 找不到“TestCase;班级)
问题描述
要使用项目的 PHPUnit 运行我的测试,我执行以下操作:php vendor/bin/phpunit tests/SomeClassTest.php
考虑到以下类声明,它可以正常工作:
To run my tests using the project's PHPUnit I do the following : php vendor/bin/phpunit tests/SomeClassTest.php
which works fine given the following class declaration :
class SomeClassTest extends PHPUnit_Framework_TestCase {
public function test_someMethod() {}
}
但是当我这样做时它失败了:
But it fails when I do this :
use PHPUnitFrameworkTestCase;
class SomeClassTest extends TestCase {
public function test_someMethod() {}
}
我得到 PHP 致命错误:找不到类 'PHPUnitFrameworkTestCase'
...
推荐答案
Class TestCase
从 PHPUnit 5.4 开始存在.如果你设置了 5.3 标签,你可以在 github 上看到它(寻找 ForwardCompatibility
文件夹)或者您可以比较 5.3 和 5.4 在 2.为 PHPUnit 编写测试
部分,上面写着:
Class TestCase
exists since PHPUnit 5.4. You can see it on github if you set 5.3 tag (look for ForwardCompatibility
folder) or you can compare doc for 5.3 and 5.4 in the 2. Writing Tests for PHPUnit
section where it says:
ClassTest (大部分时间)继承自 PHPUnit_Framework_TestCase." 对于 PHPUnit 5.3
"ClassTest inherits (most of the time) from PHPUnit_Framework_TestCase." for PHPUnit 5.3
和
ClassTest (大部分时间)继承自 PHPUnitFrameworkTestCase." 对于 PHPUnit 5.4
"ClassTest inherits (most of the time) from PHPUnitFrameworkTestCase." for PHPUnit 5.4
这篇关于PHPUnit 找不到“TestCase";班级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:PHPUnit 找不到“TestCase";班级


基础教程推荐
- 在PHP中根据W3C规范Unicode 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 如何替换eregi() 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01