![](/img/trans.png)
[英]Failing tests when using PHPUnit with code coverage and Travis CI
[英]PHPunit no tests execute on Travis CI
我第一次關注PHPUnit教程,我的測試在本地運行良好。 但是,在Travis CI上運行我的測試時,沒有執行測試,我的構建退出0。
我的目錄結構和完整代碼可以在repo上看到。
從Travis CI 構建日志(完整構建日志)
1.51s$ curl -s http://getcomposer.org/installer | php
#!/usr/bin/env php
All settings correct for using Composer
Downloading...
Composer successfully installed to: /home/travis/build/idavidmcdonald/phpunit-tutorial/composer.phar
Use it: php composer.phar
before_script.2
0.33s$ php composer.phar install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
0.08s$ vendor/bin/phpunit --debug
PHPUnit 3.7.14 by Sebastian Bergmann.
Configuration read from /home/travis/build/idavidmcdonald/phpunit-tutorial/phpunit.xml
Time: 13 ms, Memory: 2.00Mb
No tests executed!
The command "vendor/bin/phpunit --debug" exited with 0.
Done. Your build exited with 0.
phpunit.xml:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true" bootstrap="vendor/autoload.php">
<testsuites>
<testsuite name="Application Test Suite">
<directory>phpunittutorial/tests/</directory>
</testsuite>
</testsuites>
</phpunit>
.travis.yml:
language: php
php:
- 5.4
- 5.5
before_script:
- curl -s http://getcomposer.org/installer | php
- php composer.phar install
script: vendor/bin/phpunit --debug
我的測試在本地成功運行,但是我的phpunit.xml文件可能存在問題?
包含測試的目錄不正確。
正確的路徑是phpUnitTutorial/tests
。 請注意,Windows不關心區分大小寫,但世界上其他所有人都關心。 最好的辦法是始終使用小寫的路徑,或者仔細檢查你到處使用正確的大小寫(PSR-0和PSR-4需要路徑名稱與類名相同的情況,通常包括大寫字母)。
順便說一句:您應該升級到更新版本的PHPUnit。 那個舊的3.7系列現在多年來沒有得到任何更新,而向4.x的過渡並不是太陡 - 你應該這樣做。
language: php
php:
- 5.4
- 5.5
install: composer install
script: ./vendor/bin/phpunit
不確定install: composer install
,可能會省略
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.