August 15, 2008

Create FogBugz Bug on Test Run Failure

Helix ALM

Works with TestTrack 2008 and later

Works with FogBugz 5.0+

This sample uses a TestTrack trigger to create a bug in FogBugz upon a failed test run. You'll need:
  • An existing FogBugz installation and the necessary permissions to create bugs and access their REST API.
  • Permissions within your TestTrack project to create executable triggers.
You'll get:
  • An automated TestTrack trigger that creates a bug in FogBugz when a test run fails.


The download contains the source files and binaries needed for this sample. Download the Create Bug on Failed Test Run zip file.
  • CreateBug.exe - Executable built with C# .Net and Visual Studio 2005. This script handles pulling the test run information from TestTrack TCM, and creating the new bug in FogBugz.
  • CreateBug.bat - Batch file that acts an intermediary between the TestTrack trigger and the CreateBug.exe.
  • Source Code - Visual Studio 2005 solution and all required source code to build the CreateBug.exe. You only need this if you want to make changes to the script. If you follow the steps in this article, the included .exe will work just fine.

Create TestTrack Trigger

You need to create a trigger in your TestTrack project to call the CreateBug.bat you just downloaded.
  1. Login to your TestTrack project.
  2. Choose Tools > Administration > Automation Rules. Click the Triggers tab.
  3. Change the Type drop-down to Test Runs.
  4. Click Add to create a new trigger. Enter a trigger name, such as Create FogBugz Bug.
  5. Click the Trigger When tab, select After Save then Test Run enters the Failed state. This creates a trigger that executes after a test run .
    Note: this is dependent on your workflow, so if you don't have a Failed state, pick some other state.
  6. Click the Actions tab, click Add and select Run executable from the list.
  7. Enter the path to the CreateDefect.bat you downloaded, being sure to wrap the path in quotes if it contains spaces.
You're all setup in TestTrack. Now you need to edit the CreateBug.bat to call the CreateBug.exe with the necessary parameters. When calling CreateBug.exe, you need to pass your FogBugz Api Url, project, username (email address) and password in plain text. For example, C:CreateBug.exe "Sample Project" "myemailaddr" "mypwd"

Try It

The only thing left to do is to fail a test run in TestTrack TCM. If you're using the default workflow, you can simply Quick Fail a test run, and you should get a new bug created in FogBugz.

Tech Details and Notes

This sample was written and tested using the FogBugz 6.0 API and TestTrack Studio 2008. This sample uses a C# Api wrapper to simplify interaction with the FogBugz api. This wrapper was not developed by Seapine and is the property of it's respective owner(s). The following data is included in the FogBugz bug:
  • Project is set to the project parameter you pass in.
  • Category is set to Bug.
  • Title is set to the test run's summary.
  • A bug event is added with the test run's number, ttstudio hyperlink and description.
Note: Seapine does not provide support for sample triggers.