Skip to content

Ticket Listener

elblinkin edited this page Dec 21, 2011 · 4 revisions

Extension available from Sebastian Bergmann as of PHPUnit 3.6

No longer exists in the Etsy extensions as of v0.2.1

This is a tutorial for using https://github.com/sebastianbergmann/phpunit-ticketlistener-jira.

PHPUnit has an extension point for adding a Test Listener.

Enabling a test listener requires setting up the test listener in the PHPUnit XML Config.

One particular class of test listeners are ticket listeners. Ticket listeners look at the @ticket annotation in the PHPDoc of the test method, and then re-opens closed tickets for failing tests and closes open tickets for passing tests.

/**
 * @ticket BUG-123
 */
public function testBug123Regression() {
    ... test code here ...
}

Jira


The Jira ticket listener set up requires Jira connection information:

  • Jira WSDL
  • Jira username
  • Jira username's password
<string>$wsdl</string>
<string>$username</string>
<string>$password</string>

Jira allows customization of available statuses, so a list of open statuses

 <array>
   <element key="0">
     <string>New</string>
   </element>
   <element key="1">
     <string>In Progress</string>
   </element>
   <element key="2">
     <string>Reopened</string>
   </element>
 </array>

and a list of closed statuses

 <array>
   <element key="0">
     <string>Completed</string>
   </element>
   <element key="1">
     <string>Closed</string>
   </element>
 </array>

Jira then resolves and reopens via workflow actions, so the last two parameters that need to be specified are those workflow actions.

 <string>Resolve Issue</string>
 <string>Reopen Issue</string>

Put all of this together into a PHPUnit XML listener specification.

<listeners>
  <listener class="PHPUnit_Extensions_TicketListener_Jira">
    <arguments>
      <string>$wsdl</string>
      <string>$username</string>
      <string>$password</string>
      <array>
        <element key="0">
          <string>New</string>
        </element>
        <element key="1">
          <string>In Progress</string>
        </element>
        <element key="2">
          <string>Reopened</string>
        </element>
      </array>
      <array>
        <element key="0">
          <string>Completed</string>
        </element>
        <element key="1">
          <string>Closed</string>
        </element>
      </array>
      <string>Resolve Issue</string>
      <string>Reopen Issue</string>
    </arguments>
  </listener>
</listeners>

WARNING: Make sure you have a fast connection to Jira, and that you monitor usage of this feature. Each @ticket usage will result in a couple requests to Jira.

Clone this wiki locally