简体   繁体   English

我如何告诉phpunit在哪里可以找到源代码和测试

[英]How can I tell phpunit where the source and tests can be found

I am a newbie with phpunit but I need it to test something 我是phpunit的新手,但是我需要它来测试一些东西

So, suppose that have the following folders 因此,假设具有以下文件夹

mainFolder/SRC/x/y/sourceFiles.php
mainFolder/TESTS/x/y/testFiles.php
mainFolder/TESTS/bootstrap.php

When I run phpunit mainFolder it tells me: 当我运行phpunit mainFolder时,它告诉我:

Fatal error: Class 'x/y/sourceFile' not found in mainfolder/tests/x/y/testfile.php on line 28 致命错误:在第28行的mainfolder / tests / x / y / testfile.php中找不到类'x / y / sourceFile'

Note that I am a newbie, and I need some help. 请注意,我是新手,需要帮助。 Thanks 谢谢

The test files should be able to find the tested classes. 测试文件应该能够找到被测试的类。 Which means you have to require them, or set up a proper autoloading mechanism or pre-load them in a bootstrap file. 这意味着您需要它们,或者设置适当的自动加载机制,或者将它们预加载到引导文件中。 And probably there are lots of other ways to do this. 可能还有许多其他方法可以做到这一点。 The test files behave exactly the same in this sense like simple php files. 在这种意义上,测试文件的行为与简单的php文件完全相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM