mysql - 有没有办法将 RC Selenium 测试错误/失败记录到数据库中?

标签 mysql selenium phpunit phpundercontrol

我在 php 中使用 phpunit 在控制下在每个构建上运行 RC Selenium。

最佳答案

PHPUnit 允许您实现自己的TestListener。自定义测试监听器实现 PHPUnit_Framework_TestListener 接口(interface)中的抽象方法。具体来说,您的监听器将实现:

  • startTestSuite()
  • endTestSuite()
  • 开始测试()
  • endTest()
  • addError()
  • addFailure()
  • addSkippedTest()
  • addIncompleteTest()

附加 TestListner 后,每次测试套件中发生相应事件时都会调用这些方法。这些方法将被编写为对您将创建的测试结果数据库执行插入更新

将监听器类附加到您的套件就像将 标记添加到 phpunit.xml 配置文件中一样简单。例如:

<phpunit>
  <testsuites>[...]</testsuites>
  <selenium>[...]</selenium>
  <listeners>
    <listener class="Database" 
              file="/usr/loocal/share/pear/PHPUnit/Util/Log/Database.php">
  </listeners>
</phpunit>

这就是您所需要的!

事实上,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)

关于mysql - 有没有办法将 RC Selenium 测试错误/失败记录到数据库中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1612915/

相关文章:

mysql - 键不在表中,但它是

php - 使用 PHPUnit 和半持久数据库进行单元测试

php - PDO 无法将行移动到不同的数据库

php - SQL插入: syntax error in PHP

php - 制作群组成员 View 加入群组的页面

junit - Maven - Selenium - 可能只运行一个测试

Python Selenium Webdriver - 即时更改代理设置

python - 使用 Python Selenium 在输入字段中键入时出错

php - 强密码验证 laravel

php - 功能测试多语言 Symfony2 应用程序