简体   繁体   English

测试PHPUnit

[英]Testing PHPUnit

I'm running the unit tests included in PHPUnit to verify my installation. 我正在运行PHPUnit中包含的单元测试来验证我的安装。

I get the same results running from the IDE and from the command line. 我从IDE和命令行运行得到的结果相同。

Says it can't find the Success class. 说找不到成功类。 But the IDE finds it with no problem in C:\\Users\\user\\Documents\\Projects\\PHP\\vendor\\phpunit\\phpunit\\tests\\_files with all the rest of the support files. 但是IDE可以在所有其他支持文件的C:\\ Users \\ user \\ Documents \\ Projects \\ PHP \\ vendor \\ phpunit \\ phpunit \\ tests \\ _files中找到它。

I can't see any reason for it not to be found. 我看不出没有找到它的任何原因。

"C:\\Program Files\\PHP\\5.6\\php.exe" C:/Users/user/AppData/Local/Temp/ide-phpunit.php --configuration C:\\Users\\user\\Documents\\Projects\\PHP\\vendor\\phpunit\\phpunit.xml “ C:\\ Program Files \\ PHP \\ 5.6 \\ php.exe” C:/Users/user/AppData/Local/Temp/ide-phpunit.php-配置C:\\ Users \\ user \\ Documents \\ Projects \\ PHP \\ vendor \\ phpunit \\ phpunit.xml

Testing started at 4:26 AM ... 测试于4:26 AM开始...

PHP Fatal error: Class 'Success' not found in C:\\Users\\user\\Documents\\Projects\\PHP\\vendor\\phpunit\\phpunit\\tests\\Extensions\\RepeatedTestTest.php on line 23 PHP致命错误:在第23行的C:\\ Users \\ user \\ Documents \\ Projects \\ PHP \\ vendor \\ phpunit \\ phpunit \\ tests \\ Extensions \\ RepeatedTestTest.php中找不到类“成功”

PHP v 5.6 PHP v 5.6

PHPUnit v 5.0.3 PHPUnit v 5.0.3

EDIT: The one change I made to the setup was adding a phpunit.xml to allow testing. 编辑:我对安装程序所做的一项更改是添加了一个phpunit.xml以进行测试。

<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true">
<testsuites>
    <testsuite name="PHPUnit Test Suite">
        <directory>./php-code-coverage/tests/</directory>
        <directory>./php-file-iterator/tests/</directory>
        <directory>./php-text-template/tests/</directory>
        <directory>./php-timer/tests/</directory>
        <directory>./php-token-stream/tests/</directory>
        <directory>./phpunit/tests/</directory>
        <directory>./phpunit-mock-objects/tests/</directory>
    </testsuite>
</testsuites>
</phpunit>

I can't comment due to my lack of reputation. 由于缺乏声誉,我无法发表评论。 What I usually do in this situation is to activate all PHP errors at the beginning of the main unit tests file: 在这种情况下,我通常要做的是在主要单元测试文件的开头激活所有PHP错误:

// Activate all PHP type errors
error_reporting( E_ALL );
ini_set( "display_errors", "On" );

Since this shows every single warning and notice, this can help to find an include which is not working well in the command line context. 由于这显示了每个警告和注意事项,因此可以帮助查找在命令行上下文中效果不佳的include

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM