0

在写这篇文章之前,我搜索了这个主题,但没有关于我的具体问题的结果。

我最近开始使用 PHPunit。我的 IDE(来自 Nusphere 的 PHPED)仅支持最高版本 5.2.12 的 Phpunit。有些东西不能正常工作,因为PHPunit从命令行报告了一个错误:

致命错误:第7 行的 C:\Users\myuser\myproject\testunit\ConfigTest_stackoverflow.php 中找不到类'PHPUNIT\Framework\TestCase'

与 5.5.4 版相同的测试工作正常。出于调试目的,我使用了最少的代码(不自动加载,不依赖其他文件等)。当然,我尝试使用自动加载,并且版本 5.5.4 可以正常工作。代码如下:

use PHPUNIT\Framework\TestCase;


class StackTest extends testcase
{ 
    public function testMod0001T00010_Createconfigfiles() 
    {
       //Here my tests
    }
} 
**For PHPunit 5.5.4 this is the output
PHPUnit 5.5.4 by Sebastian Bergmann and contributors.
.                                                                   1 / 1 (100%)
Time: 491 ms, Memory: 15.25MB
OK (1 test, 0 assertions)**

这是预期的。

所以,我猜每个版本的 PHPUnit 的测试类定义是不同的。最后我可以使用命令行,但通过 IDE 使用它更舒适。

谢谢你。

4

1 回答 1

0

这应该有效。

use PHPUnit\Framework\TestCase;


class StackTest extends PHPUNIT_Framework_TestCase
{ 
    public function testMod0001T00010_Createconfigfiles() 
    {
       //Here my tests
    }
} 
于 2016-09-14T09:13:05.003 回答