The following example illustrates how you can automatically generate test runs based on changed files in Surround SCM.
The program first queries Surround SCM for changes in a specified repository in a specified branch within a specified time range.
If there are files that have changed, the program then checks the TestTrack project for any test cases that have any of the files attached in the source code tab.
For any test case that has a changed source code file attached, a test run is generated for every combination of "included" test variants.
- The SOAP SDK must be installed and working.
- The Surround SCM Command Line Interface (CLI) must be installed on the computer where the program runs. Specifically, it must be located in the C:Program FilesSeapineSurround SCM directory.
- The link between the test cases and the Surround SCM files is what drives this program. The integration between TestTrack TCM and Surround SCM must be in place and already in use.
About the program
The example is written in C# and the solution provided as an example is for Visual Studio 2008.
The program uses the Command Line Interface CLI program (sscm) to check for changes in Surround SCM. Specifically, it uses the cc
command. This command is designed specifically to be used by the CruiseControl application, but if you understand how it works and the output, you can use it for other things.
If the command returns any files, they are stored in an array. The program then uses the TestTrack SOAP SDK to log in to the TestTrack project. It gets the list of test case numbers. At this time, it returns all test cases. The method used to get this does take a filter name as a parameter. Use a filter to get a sub set of test cases.
For each test case, it checks the source code files attached to that test case. If any of the source code files match those returned by the cc command, the number is stored in an array.
Once the test case array is built, the program creates test runs for each test case.
The following information is hard coded and will have to be changed if you want to use this. You will have to recompile and build it. Remember this is just an example, not a finished product.
In a real world scenario, you would add code for the program to read this information from a config file.
The Surround SCM user used to log in with the CLI to check for changes. This username is also used in TestTrack.
The password for the above user.
The server address and port of the Surround SCM server in the <address>:<port>
The Surround SCM repository to scan for changes.
The Surround SCM branch to scan for changes.
The url path to the ttsoapcgi.exe.
The TestTrack project to query for test cases.
The name of the Test Run Set to add the test runs.
The CC command and the date range
As mentioned above, this command was written exclusively to be used by the CruiseControl integration. However, it works well for this example.
The tricky part of the command is setting up the date range. The command takes a date range in the following format:
The first date is the older date. In the example, the program gets the current date and time and assigns it to a variable. It also takes the current date and time and subtracts 24 hours and assigns this to another variable. The dates are converted to the format needed for the CC command.
You can download the Visual Studio 2008 project from here