0

我已经在以下目录结构 C:\Easy-PHP\pear\PHPUnit 中使用 pear 在 wamp 服务器中安装了 phpunit。

PHPUnit 运行良好,我可以从全局运行它,即 c:\phpUnit

我的问题是如何从目录中运行测试?

例如:

我有要在 c:\Users\j.bloggs\workspace\assets\project-name\classes\myClass.php 中测试的类

我在 c:\Users\j.bloggs\workspace\assets\project\tests\myClassTest.php 中有测试

如何设置使用 PHPUnit 以这种方式运行测试?我看过关于 phpunit.xml 和 bootstrap.php 的信息,我该如何实现这些?我还没有发现任何明确的信息。

谢谢你的帮助。

4

1 回答 1

4

When you run PHPUnit from the command line, it first looks in its existing directory for any phpunit.xml file to provide settings, and if it contains the path to a bootstrap file, then that bootstrap file will be executed beforehand.

The bootstrap file should be able to provide the source of the classes to be tested (by setting them up, if the test files themselves don't).

After that, it recursively looks in directories in the current working directory, for files that follow the naming convention XXXTest.php, then executes them.

Simply put, just navigate to your test folders and run phpunit.

于 2013-10-29T13:52:37.207 回答