繁体   English   中英

PHPUnit:使用@runTestsInSeparateProcesses时找不到模拟

[英]PHPUnit: Mockery not found when using @runTestsInSeparateProcesses

我将PHPUnit与Mockery结合使用,后者是通过composer安装的:

"require-dev": {
    "mockery/mockery": "0.9.*"
},

现在,考虑以下测试案例

<?php

use Mockery as m;

class FooTest extends PHPUnit_Framework_TestCase {
    function testFoo() {
        m::mock('DateTime');
    }
}

phpunit运行正常。 现在考虑以下几点:

use Mockery as m;

/**
 * @runTestsInSeparateProcesses
 * @preserveGlobalState disabled
 */
class FooTest extends PHPUnit_Framework_TestCase {
    function testFoo() {
        m::mock('DateTime');
    }
}

在这种情况下,我得到了一个Class 'Mockery' not found异常。

找不到Mockery -实际上,在/vendor目录中找不到任何内容,就好像作曲家的自动加载完全被搞砸了。 我同时运行了composer updatecomposer dump-autoload

phpunit.xml

<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         bootstrap="vendor/autoload.php"
         colors="true"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         processIsolation="false"
         stopOnFailure="false"
         syntaxCheck="false"
>
    <testsuites>
        <testsuite name="Package Test Suite">
            <directory suffix=".php">./tests/</directory>
        </testsuite>

    </testsuites>
</phpunit>

我使用的是PHPUnit 3.7.10,我使用命令行phpunit运行测试而没有任何参数。

我怎样才能解决这个问题?

升级到PHPUnit 4.x为我解决了此问题。

暂无
暂无

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

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