0

Im using phpunit & phpundercontrol to run the RC Selenium on every build.

hkshambesh
  • 435
  • 1
  • 5
  • 16

2 Answers2

1

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:

  • startTestSuite()
  • endTestSuite()
  • startTest()
  • endTest()
  • addError()
  • addFailure()
  • addSkippedTest()
  • addIncompleteTest()

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:

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

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)

user583752
  • 11
  • 1
0

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",

Community
  • 1
  • 1
knb
  • 9,138
  • 4
  • 58
  • 85