“测试框架意外退出";当测试通过时,但正常失败 [英] "Test Framework Quit Unexpectedly" when test PASSES but FAILS gracefully

查看:1599
本文介绍了“测试框架意外退出";当测试通过时,但正常失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在PhpStorm中运行一个特殊的PhpUnit测试,该测试的行为异常.请参阅下面的课程.

There is a particular PhpUnit test I am trying to run in PhpStorm that is behaving strangely. Please see the class below.

<?php

include_once('../ecoi/app/config.inc');

class formDataTest extends PHPUnit_Framework_TestCase {

public function testStateChange() {

$a = formData::calcCoiState(1);
$this - > assertEquals(1, $a);
   }
}

左下角的查看器会显示测试框架意外退出"错误,但直接在右侧的控制台输出显示"OK(1个测试,1个断言)..."消息,我将其解释为成功.现在这很奇怪.

The bottom left viewer spits out a "Test Framework quit unexpectedly" error but the console output directly to the right has a "OK (1 test, 1 assertion) ..." message which I've come to interpret as a success. Now this is where it gets weird(er).

将"assertEquals"参数从"1"修改为"2"将有效地使测试失败,并且左右窗格均按预期运行.可以这么说,它显然已记录为成功失败.

Modifying the "assertEquals" arguments from "1" to "2" will effectively fail the test and both the left and right panes function as expected. It's clearly logged as a successful failure, so to speak.

我有一个"MoneyTest"类,该类将通过并优雅地失败(以排除测试通过"的隐患.

I have a "MoneyTest" class that will pass and fail gracefully (to rule out that there's a blanket bug with the "passing" of a test.

include_once('selenium/Money.php');

class MoneyTest extends PHPUnit_Framework_TestCase {
// ...

    public function testCanBeNegated()
    {
        // Arrange
        $a = new Money(1);

        // Act
        $b = $a->negate();

        // Assert
        $this->assertEquals(1, $b->getAmount());
    }

    // ...
}

这个问题似乎与它试图引用的类有关.我只是不确定为什么失败会正确注册,但是通过只被部分注册.任何建议都会有所帮助,我很乐意提供其他信息.

The issue seems to have something to do with the class it's trying to reference. I'm just not sure why the fail registers appropriately, but the pass is only partially registered. Any advice would help, and I'd be happy to provide additional info.

推荐答案

此测试和phpStorm对当前版本的pHpUnit响应(4.3)的特殊解释似乎是一个根本问题.我将phpStorm实例指向3.7 phpUnit Phar,它的功能比预期的要好得多.

This seems to be an underlying issue with this test and phpStorm's particular interpretation of the current version of pHpUnit's response (4.3). I point my phpStorm instance to the 3.7 phpUnit Phar and it's functioning much more as expected.

这篇关于“测试框架意外退出";当测试通过时,但正常失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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