June 25, 2009

Defect Mover

Helix ALM

Works with TestTrack 2008.1.x and later

This is an example of a SOAP script that moves a defect or defects from one project to another. One use case for this example is for archiving old defects. This application will DELETE defects from a TestTrack project. Read this article carefully before using this in a production environment. The example application is provided as an example only, use it at your own risk. [toc]

TestTrack 2008 version

About the app

This is a command line application written in C#. The name of the application is TTArch.exe. I have also posted a Java example in the downloads section. The application takes three arguments: Source Project - The project from which defects are moved. Destination Project - The project to which defects are moved. Defect Number or Filter - Defect number to move a single defect, filter to move a group of defects. Use option -n to pass a defect number or -f to pass a filter name. If filter name has spaces, use double quotes. The syntax is as follows:
TTArch.exe <Source Project> <Destination Project> [-f<filter>|-n<defect number>]
NOTE: The application checks that there are only three arguments. If you try to pass less or more arguments the application will return an error. The following information is hard coded: Username - the username is "soap". Password - the password is "passoap" SOAP URL - the URL is http://localhost/scripts/ttsoapcgi.exe

Example syntax

Following are a couple of examples of what the command may look like:
TTArch "Sample Project" "Active Project" -n4
The above example moves defect number 4 from Sample Project to Active Project.
TTArch "Sample Project" "Active Project" -f"Old Defects"
The above example moves defects returned by the Old Defects filter from the Sample Project to the Active Project.

Issues/Limitations

This is just an example so there are still some issues/limitations. Some of these should be addressed before using this in a production environment:
  • Check ability to log into destination project: The current code deletes the defect from the source project before it tries to log in to the destination project. If the application is not able to log in to the destination project, the application will terminate without restoring the deleted defect. Logic should be changed/enhanced to prevent this possibility.
  • Required fields: You will not be able to add the defect to the destination project if this project has a required field that is empty in the defect. The defect will be deleted from the source project and not added to the destination project, essentially loosing the defect.
  • Logging: Currently the only output is to the command line. For better troubleshooting, write messages to a log file for further review.
  • No attachments: The method used to get the defect does not get the file attachments.
  • History Tab: The information on the history tab does not come over. This is proejct specific. The creation method and created by in the destination project will be by the SOAP app and user.
There may be other issues not yet identified

Download

The example Visual Studio 2005 project can be downloaded here. In the bindebug directory you can find a binary to test. I have also created a Java version. I imported the JAR file found here as well as the JARs mentioned in that same page. You can download the Java file from here.

TestTrack 2009 and later version

This version of the utility has the following changes
  • Updated java SOAP classes: The app uses updated Java SOAP classes for TestTrack 2009.
  • Safer logic: The app checks that the defect can be added to the destination project before it deletes it from the source project.
  • Attachments: Attachments are now moved as well.
  • Out of the box use: Uses an xml file to read the username, password and TestTrack SOAP url. This means that unless you find a problem, you shouldn't have to rebuild the app.

About the app

At this time I have only updated the Java version of the app. It is still command line based and takes the same three arguments. The syntax is as follows:
Java -jar DefectMover.jar <Source Project> <Destination Project> [-f<filter>|-n<defect number>]
NOTE: The application checks that there are only three arguments. If you try to pass less or more arguments the application will return an error.

Issues/Limitations

While some improvements have been made, there may still be some issues/limitations. Make a backup of the "source" project before using the utility:
  • Logging: Currently the only output is to the command line. For better troubleshooting, write messages to a log file for further review.
  • History Tab: The information on the history tab does not come over. This is proejct specific. The creation method and created by in the destination project will be by the SOAP app and user.
There may be other issues not yet identified

Config File

One of the improvements is that data is not hard coded, instead it reads a configuration file. The file is called "Config.XML" and it should reside on the same path as the JAR file. The structure of the XML file is as follows:
<TestTrackData>
  <SoapServer></SoapServer>
  <UserName></UserName>
  <Password></Password>
</TestTrackData>
A sample Config.xml file may look like this:
<TestTrackData>
  <SoapServer>http://localhost:80/scripts/ttsoapcgi.exe</SoapServer>
  <UserName>Administrator</UserName>
  <Password>password</Password>
</TestTrackData>

Download and requirements

You can download the entire NetBeans 6.5.1 project, including the built Jar file from here. The Jar file is located under the Dist folder. All you need to do is place the nescessary libraries in the lib subdirectory. You will need the TestTrack SOAP Java classes for TestTrack 2009, which you can download from here. You will also need to get the JAX-RPC 1.6 libraries. The easiest way to get these libraries may be to open the project in NetBeans and add the libraries from there. If you rebuild the project, NetBeans will place the libraries in the lib directory for you.