如何在 PHPUnit+Selenium 中运行测试?
我已经安装了所有内容,并且通过右键单击项目菜单中的测试并选择“运行”,我可以在 NetBeans 中创建和运行测试。问题是为测试打开的浏览器窗口在测试运行后立即关闭 - 这意味着我拥有的唯一报告是 NetBeans 提供的报告,但这还不够。我不认为我想使用命令行,而且我过去也没有取得太大的成功。
是否可以将浏览器指向 test.php 文件?当我尝试这样做时,我收到此错误:
致命错误:在第 275 行的 C:\xampp\php\PEAR\PHPUnit\Extensions\SeleniumTestCase.php 中找不到类“PHPUnit_Framework_TestCase”
我是否应该能够从另一台机器执行这些测试?即PC1是我专用的selenium测试盒,我想告诉它从PC2远程运行test.php。
我的测试文件应该放在哪里?
如何自定义测试脚本的报告/输出?
I have everything installed and I am able to create and run tests in NetBeans fine by right clicking the test in the project menu and selecting "Run". The problem is that the browser windows opened for the test close immediately after the test is ran - meaning that the only reporting I have is what NetBeans provides and that's not enough. I don't think I want to use the command line, plus I haven't had much success with it in the past anyways.
Is it possible to just point the browser at the test.php file? When i try to do that I get this error:
Fatal error: Class 'PHPUnit_Framework_TestCase' not found in C:\xampp\php\PEAR\PHPUnit\Extensions\SeleniumTestCase.php on line 275
Shouldn't i be able to execute these test from a different machine? ie PC1 is my dedicated selenium test box and I want to tell it to run test.php from PC2 remotely.
Where should my test files go?
How do I customize the reporting/out put from the test script?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在测试结束时添加
sleep(60)
:) 这将阻止 PHPUnit 关闭 Selenium 会话。或者,将您的 selenium 测试存储为与 Selenium IDE Firefox 扩展兼容的 html 文件,并让测试简单地在您的浏览器中运行。
You could add a
sleep(60)
at the end of your test :) This would prevent PHPUnit from closing the Selenium session.Alternatively, store your selenium tests as html files compatible with the Selenium IDE Firefox extension and let the test simply run in your browser.
我发现了如何远程运行我的测试文件 - 我刚刚创建了一个可以从命令行执行 phpunit 的脚本:
然后我只需点击该脚本的 URL 即可运行它 - 效果很好,但我仍然认为应该有更好/更简单的方法...
I found out how to run my test files remotely - i just created a script that would execute phpunit from the command line:
then I can just hit the URL of that script to have it run - works great, but I still think there should be a better/easier way...