一个实用类的phpunit警告

时间:2022-10-15 21:59:39

I use phpUnit on a integration server to run all tests and if I launch phpunit command from the command line, I receive:

我在集成服务器上使用phpUnit来运行所有测试,如果我从命令行启动phpunit命令,我会收到:

PHPUnit 3.2.18 by Sebastian Bergmann.
F..III..I......I.IIII...
Time: 6 seconds
There was 1 failure:

1) Warning(PHPUnit_Framework_Warning)
No tests found in class "TU".
FAILURES
Tests: 24, Failures: 1, Incomplete: 9.

Via apache, running the same test file:

通过apache,运行相同的测试文件:

PHPUnit 3.2.18 by Sebastian Bergmann.
..III..I......I.IIII...
Time: 7 seconds

OK, but incomplete or skipped tests!
Tests: 23, Incomplete: 9.

My TU class just include all tests classes with a $suite->addTestFile(), and which have two static functions: main() which run all the tests, and suite() which return the tests suite. But the TU class is not in the primary file given as parameter to phpunit command, it's a generic class wich scan files and list all test class.

我的TU类只包含所有带有$ suite-> addTestFile()的测试类,它们有两个静态函数:main()用于运行所有测试,而suite()用于返回测试套件。但是TU类不在作为phpunit命令的参数给出的主文件中,它是扫描文件并列出所有测试类的通用类。

I have the same problem with a class which extends PHPUnit_Framework_TestCase to add specific assert(), which is not included via $suite->addTestFile() but only by a require().

我对类扩展PHPUnit_Framework_TestCase以添加特定的assert()有同样的问题,该类不包含在$ suite-> addTestFile()中,而只包含require()。

How can I correct this? Thanks in advance

我怎么能纠正这个?提前致谢

Regards Cédric

2 个解决方案

#1


For the class wich extends PHPUnit_Framework_TestCase, it should be abstract, and the warning disapear. For the first problem, it seems it is a bug.

对于扩展PHPUnit_Framework_TestCase的类,它应该是抽象的,并且警告消失。对于第一个问题,它似乎是一个错误。

#2


Looks like you are using two different php.ini files for command line and Apache.

看起来你正在使用两个不同的php.ini文件用于命令行和Apache。

On most unixoid systems, running

在大多数unixoid系统上,运行

diff /etc/php*/*/php.ini

should show you the differences.

应该告诉你差异。

On Windows systems, use the search to find files named php.ini. In most cases, you can just copy the Apache configuration file to the CLI one.

在Windows系统上,使用搜索来查找名为php.ini的文件。在大多数情况下,您只需将Apache配置文件复制到CLI配置文件即可。

#1


For the class wich extends PHPUnit_Framework_TestCase, it should be abstract, and the warning disapear. For the first problem, it seems it is a bug.

对于扩展PHPUnit_Framework_TestCase的类,它应该是抽象的,并且警告消失。对于第一个问题,它似乎是一个错误。

#2


Looks like you are using two different php.ini files for command line and Apache.

看起来你正在使用两个不同的php.ini文件用于命令行和Apache。

On most unixoid systems, running

在大多数unixoid系统上,运行

diff /etc/php*/*/php.ini

should show you the differences.

应该告诉你差异。

On Windows systems, use the search to find files named php.ini. In most cases, you can just copy the Apache configuration file to the CLI one.

在Windows系统上,使用搜索来查找名为php.ini的文件。在大多数情况下,您只需将Apache配置文件复制到CLI配置文件即可。