如何运行存储在我的应用程序目录中的单元测试而不是PHP目录?

时间:2023-01-14 12:08:48

I've just installed PHPUnit and wrote a quick class which I saved to C:\PHP and it worked fine. If however I move the php file containing the test class to the tests directory of my application, it returns the error Class firstTest could not be found in ..

我刚刚安装了PHPUnit并编写了一个快速类,我将其保存到C:\ PHP并且工作正常。但是,如果我将包含测试类的php文件移动到我的应用程序的tests目录中,它将返回错误类,无法在...中找到firstTest。

How do I resolve the problem such that it can see the class in the application test directory?

如何解决问题,以便它可以在应用程序测试目录中看到该类?

2 个解决方案

#1


Thanks for the response - it wasn't the solution I used, but it led me to research that produced an alternative.

感谢您的回应 - 这不是我使用的解决方案,但它促使我进行研究,产生了另一种选择。

What I did was to add my PHP directory (C:\PHP) to the PATH environment variable. This allowed me to call phpunit from the tests directory of my application.

我所做的是将我的PHP目录(C:\ PHP)添加到PATH环境变量。这允许我从我的应用程序的tests目录中调用phpunit。

#2


Check your config file and ensure that the correct path to the tests dir is given.

检查配置文件并确保给出了测试目录的正确路径。

#1


Thanks for the response - it wasn't the solution I used, but it led me to research that produced an alternative.

感谢您的回应 - 这不是我使用的解决方案,但它促使我进行研究,产生了另一种选择。

What I did was to add my PHP directory (C:\PHP) to the PATH environment variable. This allowed me to call phpunit from the tests directory of my application.

我所做的是将我的PHP目录(C:\ PHP)添加到PATH环境变量。这允许我从我的应用程序的tests目录中调用phpunit。

#2


Check your config file and ensure that the correct path to the tests dir is given.

检查配置文件并确保给出了测试目录的正确路径。