有没有办法将 RC Selenium 测试错误/失败记录到数据库中?
我使用 phpunit & phpundercontrol 在每个构建上运行 RC Selenium。
Im using phpunit & phpundercontrol to run the RC Selenium on every build.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
PHPUnit 允许您实现自己的TestListener。自定义测试侦听器实现 PHPUnit_Framework_TestListener 接口中的抽象方法。具体来说,您的侦听器将实现:
一旦附加了 TestListner,每次发生相应事件时都会调用这些方法你的测试套件。将编写这些方法来对您将创建的测试结果数据库执行INSERT 和UPDATE。
将侦听器类附加到您的套件就像将 标记添加到 phpunit.xml 配置文件中一样简单。例如:
这就是你所需要的!
事实上,PHPUnit 已经附带了我刚才描述的侦听器的工作版本 (PHPUnit_Util_Log_Database),以及两个不同的数据库模式定义。
在许多系统上,此类将位于 /usr/local/share/pear/PHPUnit/Util/Log/Database.php 中,架构位于 /usr/local/share/pear/ 中PHPUnit/Util/Log/Database/MySQL.sql 和 /usr/local/share/pear/PHPUnit/Util/Log/Database/SQLite3.sql。您可能需要根据您使用的 DBMS 进行一些调整。
请参阅文档的这些部分(它不会让我发布两个链接:
http://www.phpunit.de/manual/3.4/en/extending-phpunit.html#extending-phpunit.PHPUnit_Framework_TestListener
htp://www.phpunit.de/manual/3.4/en /api.html#api.testresult.tables.testlistener
(StackOverflow 不允许我发布两个链接,因此您必须更正第二个链接中的 HTTP)
PHPUnit allows you to implement your own TestListener. Custom test listeners implement the abstract methods in the PHPUnit_Framework_TestListener interface. Specifically, your listener will implement:
Once you've attached the TestListner these methods will be called each time the corresponding events occur in your test suite. These methods will be written to perform the INSERTs and UPDATEs on a test results database that you'll create.
Attaching the listener class to your suite is as easy as adding a tag to the phpunit.xml configuration file. For example:
That's all you need!
In fact, PHPUnit already comes with a working version of the listener I just described (PHPUnit_Util_Log_Database), as well as two different database schema definitions.
On many systems this class will live at /usr/loocal/share/pear/PHPUnit/Util/Log/Database.php, and the schemas at /usr/loocal/share/pear/PHPUnit/Util/Log/Database/MySQL.sql and /usr/loocal/share/pear/PHPUnit/Util/Log/Database/SQLite3.sql. You may have to do some tweaking depending on the DBMS you're using.
See these sections of the documentation (it wont let me post two links:
http://www.phpunit.de/manual/3.4/en/extending-phpunit.html#extending-phpunit.PHPUnit_Framework_TestListener
htp://www.phpunit.de/manual/3.4/en/api.html#api.testresult.tables.testlistener
(StackOverflow won't let me post two links, so you'll have to correct the HTTP in that second one)
我正在解决同样的问题。
在此处提出了相关问题几天前。
我尝试使用 Selenium IDE、Selenium RC 和 perl。
一般策略:
您可以使较新版本的 phpunit 生成 TAP 输出(选项 --tap、--log-tap)。
(TAP 是 Test Anything Protocol - 标准化输出格式)
解析日志文件以从 TAP 解析器对象获取套件元数据,使用 perl 插入数据库,例如 "# Number of Passed": , "Failed", "Unexpectedly success",
I am working on the same problem.
Have asked a related question here a few days ago.
My attempt using Selenium IDE, Selenium RC and perl.
General strategy:
You can make newer releases of phpunit generate TAP output (options --tap, --log-tap).
(TAP is Test Anything Protocol - standardized output format)
Parse the logfile to obtain the suite metadata from the TAP parser object, insert into database using perl, e.g. "# Number of Passed": , "Failed", "Unexpectedly succeeded",