2011-09-01 122 views
3

PHPUnit的文檔說我推了所有的考試到一個文件夾,該文件夾上運行phpunit執行他們都一氣呵成:如何在phpunit中運行目錄結構化測試?

http://www.phpunit.de/manual/current/en/organizing-tests.html

但是當我嘗試在我的分叉修身的副本( https://github.com/codeguy/Slim)它不起作用!我已經通過PEAR安裝了PHPUnit,所以我不認爲這有什麼奇怪的。

下面是輸出:

[email protected]:/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 

任何想法我做錯了嗎?

-EDIT-

我正在使用PHPUnit 3.5.15。

這裏是目錄Slimtests的內容:

[email protected]:/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 
[email protected]:/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 

我真的只是分叉苗條和克隆它,沒有什麼花哨!

+0

你可以粘貼'Slim'和'tests'文件夾的內容嗎? –

+0

適合我。什麼是PHPUnit版本? – netcoder

+0

它是PHPUnit v3.5.15。我將編輯問題以包含文件夾的內容。謝謝! –

回答

2

事實證明,這個錯誤你所看到的,當你指定的文件夾,但該文件夾不包含匹配模式的*Test.php的任何文件。

但這不是我的問題。我正在使用VirtualBox在Ubuntu VM內的共享文件夾中運行測試。這顯然不適合PHPUnit。或者它可能是PHP。無論哪種方式,這是不正確的錯誤,因爲當我將文件夾移動到虛擬機內部的非共享位置時,它工作得很好。

編輯

我跑VirtualBox的4.1.0,這顯然有這個問題。升級到4.1.2修復了它,現在一切運行良好。感謝大家的幫助。

2

正常情況下,您可以在包含phpunit.xml和/或bootstrap.php的文件夾中發出phpunit命令。我的猜測是這些文件位於tests文件夾內。

.../Slim$ cd tests 
.../Slim/tests$ phpunit 
+0

謝謝!我添加了目錄內容,但不幸的是'tests'文件夾中沒有'phpunit.xml'或'bootstrap.php'。有任何想法嗎? Slim文檔說,我需要運行的是'Slim'目錄下的'phpunit tests' ... –

+0

您是否嘗試了上述命令從'tests'目錄內運行? –

+0

我做了,是的,但它只是失敗:( –

相關問題