doulu3808 2011-09-01 20:50
浏览 83
已采纳

如何在phpunit中运行目录结构化测试?

The PHPUnit docs say that I can shove all my tests into a folder and run phpunit on the folder to execute them all in one go:

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

But when I try on my forked copy of Slim (https://github.com/codeguy/Slim) it doesn't work! I have installed PHPUnit via PEAR so I don't think there's anything odd about it.

Here's the output:

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

Any ideas what I'm doing wrong?

-EDIT-

I'm using PHPUnit 3.5.15.

Here are the contents of the directories Slim and 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

I've literally just forked Slim and cloned it, nothing fancy!

  • 写回答

2条回答 默认 最新

  • douzhangcuo2174 2011-09-10 18:15
    关注

    It turns out that this error is what you see when you specify a folder but the folder doesn't contain any files that match the pattern *Test.php.

    This is NOT my problem, however. I'm running the tests from within a shared folder inside an Ubuntu VM using VirtualBox. This doesn't play well with PHPUnit, apparently. Or it might be PHP. Either way, it's incorrectly erroring because when I move the folder into a non-shared location inside the VM it works just fine.

    Edit

    I was running VirtualBox 4.1.0 which apparently has this problem. Upgrading to 4.1.2 fixed it and everything is running fine now. Thanks to everyone for their help.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧