October 20, 2008
Code Collaborator TestTrack Integration
SmartBear's CodeCollaborator is becoming a popular tool used by developers to do code reviews. CodeCollaborator offers a way to integrate with Defect tracking tools and the question has been asked if it can be integrated with TestTrack Pro. This article shows some of the integration you can set up between CodeCollaborator and TestTrack Pro. Note: This article may not cover every possible way to integrate the two applications. [toc]
Works with TestTrack 2008
Works with SmartBear Code Collaborator 4.0
CodeCollaborator Defects vs. TestTrack DefectsThere seems to be a conceptual difference between defects in CodeCollaborator and TestTrack. TestTrack defects are those that are generally found through the use of an application. They are reported by a customer, a member of the qa team, or a development team member testing out portions of the application. CodeCollaborator defects are generally those found while reviewing the code, so they may have more to do with the logic or other aspects of the code. One must consider which, if any, CodeCollaborator defects should be also tracked in TestTrack Pro. There isn't one correct answer. The answer depends on your use of both applications and on you company's process.
The integrationThe integration is setup between the CodeCollaborator server and the TestTrack web client. There are three pieces to this integration:
- Link to add defect
- Link to an existing defect
- Regular expression to link to a defect
Link to add defect
SoloSubmitThe easiest way is to open SoloSubmit. If you point the user to the generic url http://yourwebserver/ttweb/loginsolosubmit, the user may have to choose a project, if you have more than one project using SoloSubmit. You could pass instead a URL that already includes the id for the project, something like:
Add Defect pageYou could set it up so it opens the add defect page on the web client, but you would have to embed the username and password in the URL. This means everyone would use the same username and password to add defects, which would be visible in the URL. This may be a viable solution if you create a user specifically for this and create a security group for this user whose permissions allow only to add a defect. For more information on how to build this URL, read this knowledge base article
Link to existing defectThe easiest solution is to use the http:// link from the TestTrack address bar. You may be able to use the ttstudio:// link, but it will require you to configure the TestTrack URL redirector if you want it to still open the web client. For this example, the http:// link will be used.
Using the record idThe http url in the TestTrack address bar uses the record id for a defect. This is the "safest" id to use, since it will not change. If the defect is renumbered, a link that uses the record id will not be affected, it will direct you to the same defect. As indicated in the instructions for CodeCollaborator, we must place BUGID where the number should be placed. The URL may look something like this:
Using the defect numberYou can edit the URL so it uses the defect number. Most developers will not know the record id of a record, but they should know the defect number. The only risk is that if the defect is renumbered, it will no longer point the correct defect. To use the defect number instead of the record id, simply substitute "recordID" with "number". As indicated in the instructions for CodeCollaborator, we must place BUGID where the number should be placed. The same URL above now looks like this:
Regular expression to link to a defectCodeCollaborator allows you to setup a regular expression to link to a defect. It will look for the string specified in the expression and retrieve the number passed with that token. This number is then passed to the link you set up for defect linking. CodeCollaborator uses the word "case" as an example, and provide this as the reqular expression: cases*(d+) This example will use the word "ttp:", and the regular expression is: ttp:s*(d+) Figure 2 below shows the bug-tracking integration window with all three fields filled.
Using the integrationThe integration can be used when you are adding a defect in Code Collaborator, when you mark a defect to be tracked externally, or when you are reviewing a defect.
Adding a DefectWhen adding a defect, insert the token with the corresponding TestTrack defect number. For example, if you are adding a defect in Code Collaborator and you would like to link it to defect 4 in TestTrack, include the following in the comments: ttp:4 Figure 3 below shows a sample defect created in CodeCollaborator.
Track externallySelecting the option to track the defect externally gives you two options:
- Set up a link to an existing defect in TestTrack.
- Add a new defect to TestTrack (no link established).
Setting up a triggerCodeCollaborator has triggers that could be used to automate the process of creating a defect in TestTrack. Using variable substitution, you can gather data about the review and defect and pass it to TestTrack. The following example is a trigger that adds a defect to TestTrack with data gathered using variable substitution. This example will add every CodeCollaborator defect into TestTrack. This is something that may not be desired, as discussed at the beginning of this article.
The triggerIn the trigger section you have a specific area for defect triggers. While this is advantageous, it is one trigger for any defect action. This means that the trigger will fire if it is an add defect action, an edit defect action, a fix defect action, etc... There does not appear to be a way to filter which action fired the trigger. This means your script will have to try to figure this out, or at least take it into account. In the sample script, since its only purpose is to add a defect, it only tries to prevent creating duplicates.
The scriptThe sample script is written in C# using Visual Studio 2005, so if you would like to use the .exe you will need to have the .NET framework version 2.0 or higher. The script takes the following parameters:
- SOAP server URL
- TestTrack project name
- TestTrack username
- TestTrack password
Field MappingThe script will map the defect severity field in CodeCollaborator and map it to the severity field in TestTrack. The Type field in CodeCollaborator is mapped to the Type field in TestTrack. This script does not check if the values in Code Collaborator exist in TestTrack. If the values do not exist in TestTrack, the add defect operation will fail. This can be addressed by ensuring that both applications have the same values for these fields, or adding a method to the script to check the values for these fields and add them if they are not found. The Comment field is mapped to the description field and a custom defect field called Summary in CodeCollaborator is added to map it to the summary field in TestTrack. The script expects the full user name in CodeCollaborator to be in the format FirstName LastName. It then modifies it to be in the format LastName, FirstName when it sets the Entered By field in TestTrack. The CodeCollaborator defect id and review id are used to build a string in the following format: <review id>:<defect id> This value is stored in the TestTrack defect reference field and is used to see if the CodeCollaborator defect already exists in TestTrack to determine if the defect should be created in TestTrack.
DownloadThe sampe script is available for download. However, it is provided as an example only. Unless your CodeCollaborator environment and TestTrack project are set up exactly the same, this script will require modifications. Seapine's Professional Services are available if you require a custom solution. The sample script is available for download here. It includes the Visual Studio 2005 project and the debug built binaries.
SetupThe trigger setup consists of two text boxes:
"http://localhost/scripts/ttsoapcgi.exe" "Sample Project" "Administrator" "" $defect.text $defect.custom.Severity $defect.custom.Type $defect.custom.Summary $user.name $defect.id $review.idFigure 6 below illustrates the trigger setup.