July 21, 2016
Schedule and Email TestTrack Reports Automatically
Here at Seapine, we're huge fans of automating as many tasks as possible. For example, sometimes it's useful to schedule a TestTrack report to run and automatically be emailed to a manager or other stakeholder. Let’s take a look at how to make that happen. It’s not too difficult to set up. TestTrack's SOAP interface already allows you to run most reports. Combine that with Blat (http://www.blat.net) for email capabilities and your operating system's job scheduler, then glue the pieces together with a little bit of scripting. See runScheduledReport.pl in this .zip file for a script to do just that. You can also trigger the script using TestTrack's executable triggers feature if you need reports run when something happens in TestTrack. I'm going to take this opportunity to demonstrate a less well-known method of using SOAP than through the typical HTTP server method—calling the SOAP CGI application from the command line instead. This can sometimes simplify development and speed up the resulting app. See the subroutines “RunSoapXML” and “RunSoapXMLFile” in runScheduledReport.pl in the .zip file. Like any other command line tool, you can feed the SOAP CGI input from a file—in this case, a file containing XML. When using the SOAP CGI in this way, the web server is completely bypassed. That can speed up things like local SOAP triggers by skipping some network and web server overhead. This method isn't appropriate for all circumstances—for instance, it may require an extra installation of the SOAP CGI, which then has to be upgraded each time TestTrack is.
InstallationIn this example, I’ll be using the Windows OS. (A Linux implementation would need to substitute sendmail for Blat, cron for Task Scheduler, flip “\” to “/”, and remove “.exe” from various file names. An OS X implementation would need to use the standard HTTP method of SOAP invocation, because there’s no SOAP CGI for OSX.)
- Create "C:\scheduledReport\"
- Download Blat from http://www.blat.net into the directory from step 1.
- Locate ttsoapcgi.exe (normally installed to your web server's "scripts" or "cgi-bin" directory) and copy it to the directory from Step 1.
- Download and unzip the demo script and XML into the directory from Step 1.
- If you haven't already, install a Perl interpreter (http://www.activestate.com/activeperl).
ConfigurationAfter download, configure Blat using "blat -install < SMTP server address > < sender's email address > [< try > [< port > [< profile >]]] [-q]" at the command line. If you haven't previously configured ttsoapcgi.exe on the machine you’re using, you'll need to set up your TestTrack server connection information using the registry utility. Once all that’s done, create a configuration text file consisting of the following five lines:
- A comma-separated list of recipient email addresses
- A TestTrack username that has permissions to log in using SOAP and run reports
- The password for the above username
- The name of the TestTrack project where the report resides
- The name of the report to run (Note: some report types, such as live charts, are not supported by SOAP)
[email protected],[email protected] ReportRunnerUser SecretPassword Sample Project Issue by Assigned User Report
TestingNow is a good time to test that everything is set up correctly. Open the command line, switch to the above directory, and type:
runScheduledReport.pl "< config file name >"If all goes well, the recipient(s) should receive a fresh copy of the report by email.