簡體   English   中英

全局PHPunit未執行測試

[英]Global PHPunit no tests executed

我有以下phpunit.xml文件:

<phpunit bootstrap="Bootstrap.php" backupGlobals="false">
    <testsuites>
        <testsuite name="mentor">
            <directory>../module/Api</directory>
            <directory>../module/Application</directory>
            <exclude>../vendor</exclude>
          <exclude>vendor</exclude>
        </testsuite>
    </testsuites>
    <filter>
        <whitelist>
            <directory suffix=".php">../module</directory>
        </whitelist>
    </filter>
</phpunit>

文件結構如下所示:

module
vendor
tests
-- phpunit.xml
-- Bootstrap.php

現在是棘手的部分。 當我運行../vendor/bin/php時,雖然我運行了全局phpunit(/ usr / local / bin / phpunit),但一切正常,但結果為“未執行測試”。 有什么建議么?

我發現了phpunit省略所有類的原因-這是由於我試圖擴展的 TestCase所致。 我所有的測試都是通過Phpunit 5.7軟件包(在供應商中)在\\ PHPUnit_Framework_TestCase上進行的。 phpunit 6.1.4使用名稱空間代替,因此我應該擴展PHPUnit \\ Framework \\ TestCase 通過更改測試中的擴展類,一切正常。

我認為您需要像這樣在作曲家內部使用psr-4:

"autoload": {
        "psr-4": {
            "": "module/"
        }
}

在需要使用以下命令更改phpunit.xml之后:

<phpunit bootstrap="Bootstrap.php" backupGlobals="false">
    <testsuites>
        <testsuite name="mentor">
            <directory>module/Api</directory>
            <directory>module/Application</directory>
            <exclude>../vendor</exclude>
          <exclude>vendor</exclude>
        </testsuite>
    </testsuites>
    <filter>
        <whitelist>
            <directory suffix=".php">module</directory>
        </whitelist>
    </filter>
</phpunit>

我認為您需要將phpunit點更改為文件夾測試而不是模塊! 像這樣:

<phpunit bootstrap="Bootstrap.php" backupGlobals="false">
        <testsuites>
            <testsuite name="mentor">
                <directory>tests/</directory>
                <exclude>../vendor</exclude>
              <exclude>vendor</exclude>
            </testsuite>
        </testsuites>
        <filter>
            <whitelist>
                <directory suffix=".php">tests</directory>
            </whitelist>
        </filter>
    </phpunit>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM