执行文件夹下所有php,php-如何获取phpunit从文件夹中的所有文件运行测试?

从我阅读的内容来看,似乎应该可以设置一个文件夹,例如 tests /,在其中放入一些带有单元测试类的文件,然后在该文件上运行phpunit并使其查找并运行测试。

无论出于何种原因,在我的安装中(在OS X上),它都认为文件夹tests /是一个文件,或者看起来是这样:

$ ls tests

test1.php test2.php

$ phpunit tests/test1.php

PHPUnit 3.5.3 by Sebastian Bergmann.

F

Time: 0 seconds, Memory: 5.00Mb

There was 1 failure:

1) FailingTest::testFail

Your test successfully failed!

/Users/****/tmp/tests/test1.php:4

FAILURES!

Tests: 1, Assertions: 0, Failures: 1.

$ phpunit tests/test2.php

PHPUnit 3.5.3 by Sebastian Bergmann.

.

Time: 0 seconds, Memory: 5.00Mb

OK (1 test, 1 assertion)

$ phpunit tests

PHP Fatal error: Uncaught exception 'PHPUnit_Framework_Exception' with message 'Neither "tests.php" nor "tests.php" could be opened.' in /usr/local/PEAR/PHPUnit/Util/Skeleton/Test.php:102

Stack trace:

#0 /usr/local/PEAR/PHPUnit/TextUI/Command.php(157): PHPUnit_Util_Skeleton_Test->__construct('tests', '')

#1 /usr/local/PEAR/PHPUnit/TextUI/Command.php(129): PHPUnit_TextUI_Command->run(Array, true)

#2 /usr/local/bin/phpunit(53): PHPUnit_TextUI_Command::main()

#3 {main}

thrown in /usr/local/PEAR/PHPUnit/Util/Skeleton/Test.php on line 102

Fatal error: Uncaught exception 'PHPUnit_Framework_Exception' with message 'Neither "tests.php" nor "tests.php" could be opened.' in /usr/local/PEAR/PHPUnit/Util/Skeleton/Test.php:102

Stack trace:

#0 /usr/local/PEAR/PHPUnit/TextUI/Command.php(157): PHPUnit_Util_Skeleton_Test->__construct('tests', '')

#1 /usr/local/PEAR/PHPUnit/TextUI/Command.php(129): PHPUnit_TextUI_Command->run(Array, true)

#2 /usr/local/bin/phpunit(53): PHPUnit_TextUI_Command::main()

#3 {main}

thrown in /usr/local/PEAR/PHPUnit/Util/Skeleton/Test.php on line 102

我希望按照以下说明在操作系统上通过PEAR进行相当标准的phpunit安装: X雪豹。

$ pear version

PEAR Version: 1.9.1

PHP Version: 5.3.2

Zend Engine Version: 2.3.0

Running on: **** 10.4.0 Darwin Kernel Version 10.4.0: Fri Apr 23 18:28:53 PDT 2010; root:xnu-1504.7.4~1/RELEASE_I386 i386

$ phpunit --version

PHPUnit 3.5.3 by Sebastian Bergmann.

我希望其他人遇到这个问题,这只是一个简单的解决方法,否则我只是做错了什么?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值