我第一次学习 PHPUnit 教程,我的测试在本地运行良好。但是,在 Travis CI 上运行我的测试时,没有执行任何测试,我的构建以 0 退出。
我的目录结构和完整代码可以在 repo 上看到.
Travis CI 构建日志 (Full build log)
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 的过渡也不是太陡峭 - 你应该这样做。
关于PHPunit 没有在 Travis CI 上执行测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30280278/