【问题标题】:Travis CI only executing single test file phpunitTravis CI 只执行单个测试文件 phpunit
【发布时间】:2016-08-10 21:25:08
【问题描述】:

我在使用 Travis CI 和 PHPUnit 时遇到了一点问题——它似乎只执行了一个测试文件——奇怪的是——tests/unit/helpers/XMLFileTest.php。

https://travis-ci.org/Matt-Barber/DataCruncher/jobs/151193473

这是我正在使用的 phpunit.xml.dist 的副本:

<phpunit
    convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
strict="true"
bootstrap="vendor/autoload.php"
verbose = "true"
>
<testsuites>
    <testsuite name="unit">
        <directory suffix='.php'>./tests/unit</directory>
    </testsuite>
    <testsuite name="integration">
        <directory suffix='.php'>./tests/integration</directory>    
    </testsuite>
    <testsuite name="functional">
        <directory suffix='.php'>./tests/functional</directory>
    </testsuite>
</testsuites>
<logging>
    <log type="coverage-html" target="build/coverage" title="CSV_Cruncher" charset="UTF-8" yui="true" highlight="true" lowUpperBound="35" highLowerBound="70"/>
    <log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
<filter>
    <whitelist addUncoveredFilesFromWhitelist="true">
        <directory suffix=".php">./src</directory>
    </whitelist>
</filter>
</phpunit>

还有我正在使用的 travis.yml

language: php
php:
    - '5.6'
    - '7.0'

before_script:
    - composer install
    - find . -type f -name *.csv -exec chmod 777 {} +
    - mkdir build

script: 
    - phpunit --configuration phpunit.xml.dist --debug

after_script: 
    - php vendor/bin/coveralls -v

我的 src 的文件夹结构是:

src
    - Analysis
        - Statistics.php
    - Config
        - Validation.php
    - Exceptions
        - [various]
    - Helpers
        - DataInterface.php
        - DataFile.php
        - CSVFile.php
        - XMLFile.php
    - Segmentation 
        - Merger.php
        - Query.php
        - Split.php

测试是一样的:

tests
    - unit
        - Analysis
            - StatisticsTest.php

等等……

这里是 git repo 的链接 https://github.com/Matt-Barber/DataCruncher/tree/develop

其他测试没有执行的任何原因?它们在本地和通过带有 XDebug 的流浪机器上运行似乎都很好......它伤害了我的大脑(正如你从提交历史中看到的那样)

任何问题,非常感谢您的帮助!

干杯!

更新

答案是记住

mv Folder folder

不一样
git mv Folder folder

谢谢你!指出差异!

【问题讨论】:

    标签: php testing continuous-integration phpunit travis-ci


    【解决方案1】:

    这是区分大小写的简单问题。您已在 phpunit.xml.dist 中将测试目录指定为 ./tests/..,并且您的 repo 具有以下结构:

    Tests/[...]
    tests/unit/Helpers/XMLFileTest.php
    

    PhpUnit 只会在 Travis 上找到第二个。只要确保在任何地方都使用相同的大小写。

    【讨论】:

    • 不敢相信我错过了...谢谢! mv 和 git mv doh!
    • 我从自己的经验中肯定知道这些问题;)
    猜你喜欢
    • 2015-07-28
    • 1970-01-01
    • 1970-01-01
    • 2015-10-18
    • 2017-10-19
    • 1970-01-01
    • 2013-09-04
    • 2016-05-09
    • 1970-01-01
    相关资源
    最近更新 更多