PHPUnit 中的全局常量
有没有一种方法可以在 PHPUnit 中定义可在所有测试套件中使用的常量?例如,假设我希望能够有时在 jason.dev.mysite.com 上进行测试,有时在 jim.dev.mysite.com 上进行测试,并且可能会指定当我在要测试的站点上运行命令时。这样的事情可能吗?
我发现的最接近的是: http://www.phpunit.de /manual/3.4/en/appendixes.configuration.html
Is there a way to define constants in PHPUnit that can be used in all your test suites? For example, say I want to be able to test on jason.dev.mysite.com sometimes and jim.dev.mysite.com sometimes, and maybe specify when I run the command on which site I want to test. Is anything like this possible?
The closest thing I found was this: http://www.phpunit.de/manual/3.4/en/appendixes.configuration.html
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这应该在引导文件中。
检查此处:http://www.phpunit.de/manual/current/en/ textui.html 用于引导文件选项。
您还可以查看
setUp()
和setUpBeforeClass()
方法,但它们仅与一个测试类相关。This should be in the bootstrap file.
Check here : http://www.phpunit.de/manual/current/en/textui.html for the bootstrap file option.
You can also check out the
setUp()
andsetUpBeforeClass()
methods, but they are related to one test class only.对于那些已经有了引导程序并且想要单独定义常量的人,请检查 XML 配置文件。该链接似乎会随着版本更新而定期更改,因此示例如下:
For those who already have a bootstrap and are wanting to define a constant separately checkout the
<php>
tag in the XML Configuration file. The link seem to change on a regular basis with version updates so an example is: