命令行中的PHPUnit-显示的依赖项列表.如何使其仅显示测试脚本? [英] PHPUnit from command line - list of dependancy files displayed. How can I make it display only the test script?

查看:66
本文介绍了命令行中的PHPUnit-显示的依赖项列表.如何使其仅显示测试脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Windows 7以及PHP和Pear上安装了PHPUnit.

I have installed PHPUnit on Windows 7, with PHP and Pear.

我有一个基本的测试脚本,开始于:

I have a basic test script, to start with:

<?php

class StackTest extends PHPUnit_Framework_TestCase
{
    public function testTest()
    {
        $this->assertTrue(false);
    }
}

我正在命令提示符下以以下方式运行它:

I'm running it from the command prompt as:

phpunit unittest testTest.php

并获得以下回报:

PHPUnit 3.6.5 by Sebastian Bergmann.

F

Time: 0 seconds, Memory: 2.75Mb

There was 1 failure:

1) StackTest::testTest
Failed asserting that false is true.

C:\Program Files (x86)\PHP\PEAR\pear\PHPUnit\Framework\Constraint.php:145
C:\Program Files (x86)\PHP\PEAR\pear\PHPUnit\Framework\Constraint.php:92
C:\Program Files (x86)\PHP\PEAR\pear\PHPUnit\Framework\Assert.php:2100
C:\Program Files (x86)\PHP\PEAR\pear\PHPUnit\Framework\Assert.php:854
C:\Users\lbassett\Dropbox\Projects\Test\testTest.php:10
C:\Program Files (x86)\PHP\PEAR\pear\PHPUnit\Framework\TestCase.php:939
C:\Program Files (x86)\PHP\PEAR\pear\PHPUnit\Framework\TestCase.php:801
C:\Program Files (x86)\PHP\PEAR\pear\PHPUnit\Framework\TestResult.php:649
C:\Program Files (x86)\PHP\PEAR\pear\PHPUnit\Framework\TestCase.php:748
C:\Program Files (x86)\PHP\PEAR\pear\PHPUnit\Framework\TestSuite.php:772
C:\Program Files (x86)\PHP\PEAR\pear\PHPUnit\Framework\TestSuite.php:745
C:\Program Files (x86)\PHP\PEAR\pear\PHPUnit\TextUI\TestRunner.php:325
C:\Program Files (x86)\PHP\PEAR\pear\PHPUnit\TextUI\Command.php:187
C:\Program Files (x86)\PHP\PEAR\pear\PHPUnit\TextUI\Command.php:125
C:\Program Files (x86)\PHP\PEAR\phpunit:44

FAILURES!
Tests: 1, Assertions: 1, Failures: 1.

我的问题是列出的不同文件的清单很长.

My problem is the long list of different files listed.

我只想在那里查看我的测试成绩单.我想念什么吗?

I only want to see my test scrip there. Am I missing something?

推荐答案

简短版本:

这是PHPUnit中的错误. 我已修复它.在下一个较小的发行版中它将起作用.

Short Version:

It's a bug in PHPUnit. I've fixed it. With the next minor release it will work.

您已经注意到您的文件包含在回溯中

You have already noticed that your file is included in the backtrace

 C:\Users\lbassett\Dropbox\Projects\Test\testTest.php:10

所以问题是,为什么在您的课程中还有其他所有内容.

so the question is why is there all that other stuff around your classes.

PHPUnit 进行过滤,以回溯并清除所有PHPUnit类,但是由于某些原因,这似乎不起作用.

PHPUnit should filter that backtrace and strip out all the PHPUnit classes but for some reasons that seems to not work.

Linux上的输出:

The output on linux:

PHPUnit 3.6.5 by Sebastian Bergmann.

F

Time: 0 seconds, Memory: 3.00Mb

There was 1 failure:

1) failingTest::testFail
Failed asserting that false is true.

/home/edo/phpunit-dev/oneFailingTest/failingTest.php:6

起初,我期望Program Files中的空格出现问题,但我已将其安装在没有空格的文件夹中,并且它也在那里中断".

I at first was expecting an issue with the spaces in Program Files but I've installed it in a folder without spaces and it "breaks" there too.

对我来说,这是PHPUnit中的错误.

For me this is a bug in PHPUnit.

我建议 you file an issue at the github issue tracker

I suggest you file an issue at the github issue tracker that the backtrace filtering seems broken on windows and I'll see if I can take care of that then. I've pushed a fix. It should be solved in PHPUnit 3.6.6 (when it is released). See the edits.

是的.这个问题似乎来自PHPUnit_Util_Filter :: phpunitFiles();.用\而不是/返回路径.

Yeah. The issue seems to come from PHPUnit_Util_Filter::phpunitFiles(); returning the paths with \ instead of /.

如果在412行中的PHPUnit/Util/GlobalState.php中放置以下代码.(在return语句之前)

If you put the following code in: PHPUnit/Util/GlobalState.php at line 412. (Before the return statement)

foreach(self::$phpunitFiles as $key => $value) {
    unset(self::$phpunitFiles[$key]);
    self::$phpunitFiles[str_replace("/", "\\", $key)] = $value;
}

然后您会看到一个很好的回溯轨迹.我会看到它已在3.6.6中用一个更好的补丁修复了.

then you get a nice looking backtrace. I'll see to it that it gets fixed in 3.6.6 with a nicer patch.

这篇关于命令行中的PHPUnit-显示的依赖项列表.如何使其仅显示测试脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆