[英]How do I run directory-structured tests in phpunit?
PHPUnit文檔說我可以把所有測試都推到一個文件夾中並在文件夾上運行phpunit
來一次執行它們:
http://www.phpunit.de/manual/current/en/organizing-tests.html
但是,當我嘗試我的Slim的分叉副本(https://github.com/codeguy/Slim)時,它不起作用! 我已經通過PEAR安裝了PHPUnit,所以我認為沒有什么奇怪的。
這是輸出:
mark@ubuntu:/project/submodules/Slim$ phpunit tests
PHP Fatal error: Uncaught exception 'PHPUnit_Framework_Exception' with message 'Neither "tests.php" nor "tests.php" could be opened.' in /usr/share/php/PHPUnit/Util/Skeleton/Test.php:102
Stack trace:
#0 /usr/share/php/PHPUnit/TextUI/Command.php(157): PHPUnit_Util_Skeleton_Test->__construct('tests', '')
#1 /usr/share/php/PHPUnit/TextUI/Command.php(129): PHPUnit_TextUI_Command->run(Array, true)
#2 /usr/bin/phpunit(49): PHPUnit_TextUI_Command::main()
#3 {main}
thrown in /usr/share/php/PHPUnit/Util/Skeleton/Test.php on line 102
我有什么想法我做錯了嗎?
-編輯-
我正在使用PHPUnit 3.5.15。
以下是Slim
和tests
目錄的內容:
mark@ubuntu:/project/submodules/Slim$ ls -l
total 20
-rw-r--r-- 1 mark mark 4320 Aug 23 14:41 README.markdown
drwxr-xr-x 1 mark mark 408 Aug 24 02:39 Slim
-rw-r--r-- 1 mark mark 6993 Aug 23 14:41 index.php
-rw-r--r-- 1 mark mark 1398 Aug 23 14:41 logo.png
drwxr-xr-x 1 mark mark 476 Aug 23 14:41 tests
mark@ubuntu:/project/submodules/Slim$ ls -l tests
total 104
-rw-r--r-- 1 mark mark 73 Aug 23 14:41 Foo.php
drwxr-xr-x 1 mark mark 204 Aug 23 14:41 Http
-rw-r--r-- 1 mark mark 4398 Aug 23 14:41 LogTest.php
-rw-r--r-- 1 mark mark 5088 Aug 23 14:41 LoggerTest.php
-rw-r--r-- 1 mark mark 734 Aug 23 14:41 README
-rw-r--r-- 1 mark mark 11115 Aug 23 14:41 RouteTest.php
-rw-r--r-- 1 mark mark 10327 Aug 23 14:41 RouterTest.php
drwxr-xr-x 1 mark mark 102 Aug 23 14:41 Session
-rw-r--r-- 1 mark mark 47703 Aug 23 14:41 SlimTest.php
-rw-r--r-- 1 mark mark 6447 Aug 23 14:41 ViewTest.php
drwxr-xr-x 1 mark mark 102 Aug 23 14:41 logs
drwxr-xr-x 1 mark mark 102 Aug 23 14:41 templates
我真的只是分叉了Slim並克隆了它,沒什么特別的!
通常,您在包含phpunit.xml
和/或bootstrap.php
文件夾中發出phpunit
命令。 我的猜測是這些都位於tests
文件夾中。
.../Slim$ cd tests
.../Slim/tests$ phpunit
事實證明,此錯誤是您在指定文件夾時看到的但該文件夾不包含與模式*Test.php
匹配的任何文件。
但是,這不是我的問題。 我正在使用VirtualBox在Ubuntu VM內的共享文件夾中運行測試。 顯然,這與PHPUnit不太匹配。 或者它可能是PHP。 無論哪種方式,它都是錯誤的錯誤,因為當我將文件夾移動到VM內部的非共享位置時,它可以正常工作。
編輯
我正在運行VirtualBox 4.1.0,顯然有這個問題。 升級到4.1.2修復它,現在一切正常。 感謝大家的幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.