Extending Delphi Application Testability With External Debug Info
In my previous blog post, TestComplete 7 Improvements Delphi and C++Builder Open Applications, I told you that TestComplete can now see inside Delphi applications without any special preparations. Still, even more thorough testing can be achieved if the application is compiled with debug information included. This enables TestComplete to access all native (published, public, protected and private) properties, fields and methods of applications objects just like Delphis integrated debugger can.
However, the debug information requirement raises the following problems:
- Inclusion of debug information significantly increases the application size, impairs the performance and thus makes the application non-suitable for shipping. As a result, build engineers need to create a special, debug application version in addition to the release version.
- The need to create an additional version increases the total build duration and the application cant be built as often.
- The application may function differently when built with debug settings, so the debug version being tested may function differently from the release version shipped to users.
TestComplete 7 provides a solution to these problems and lets build engineers create testable release builds of Delphi applications with external debug information. This can be accomplished by using TestCompletes new utility StripTDS (<TestComplete>BinStripTDS.exe). It strips debug information from executables and libraries created with the Delphi compilers and saves it to a separate TDS files next to the processed ones. During application testing, TestComplete reads the TDS debug information as if it were inside the applications binaries, and exposes internal properties, fields and methods of the applications objects, which then can be used in your automated tests. Theres now no need to create special application builds for TestComplete; it can now test your normal release builds using external debug information.
Creating release builds of a Delphi application with external debug information includes two steps:
- Building the application with internal TD32 debug information.
- Extracting debug information from the applications binaries using TestCompletes StripTDS utility.
Ill show you how this can be done with a Delphi version of TestCompletes sample application, Orders. The Orders application is located in the <Users>PublicDocumentsTestComplete 7 SamplesOpen AppsOrdersDemoDelphi folder on Windows Vista and Windows Server 2008 or the <Documents and Settings>All UsersDocumentsTestComplete 7 Samples folder on other Windows versions. In this little tutorial, I use CodeGear Delphi 2009 on Windows XP, but the steps for other Delphi and Windows versions are very similar.
First, Ill compile Orders with internal TD32 debug information. The steps to do this are as follows:
- Open the Orders.dpr project in Delphi.
- Open the project options.
- For CodeGear Delphi 2007 or later, select the Release build configuration.
- Enable the Debug Information and Local Symbols options in the Delphi Compiler | Compiling category:
- Enable the Debug information option in the Delphi Compiler | Linking category:
- Save and close the project options.
- For CodeGear Delphi 2007 or later, activate the Release build configuration.
- Build the project.
Now I have the Orders executable built with debug information included. The file size is ~4.6 MB; out of these the applications binary code takes ~900 KB, while the rest is debug info. To extract debug info into an external file using the StripTDS utility, I run the following command:
"C:Program FilesAutomated QATestComplete 7BinStripTDS.exe" -w "C:Documents and SettingsAll UsersDocumentsTestComplete 7 SamplesOpen AppsOrdersDemoDelphiOrders.exe"
Note: Here, the -w argument specifies that StripTDS should replace the resulting debug information file if it already exists. You can read more about StripTDSs command line in TestCompletes help.
After processing the Orders executable with StripTDS, I get two files:
- Orders.exe (~900 KB) this is the applications stripped binary file; the release version clear of debug info and ready for shipping to users.
- Order.tds (~3.7 MB) this file contains debug information extracted from Orders.exe. This file isnt needed to run Orders; its only used by TestComplete. For testing purposes, this file must be kept in the same folder as Orders.exe.
Lets launch Orders and view it in the Object Browser. For TestComplete 7, theres no difference whether the debug information is included in the applications binary files or kept outside of them. Notice the objects internal properties, fields and methods that became accessible to TestCompletes automated tests due to debug info:
The new StripTDS utility included in TestComplete 7 provides a solution for Delphi application developers that want to create testable release builds. Now they dont need to build an additional debug version to run automated tests on, or worry that the build being tested is different from the one shipped to users. StripTDS makes it possible to keep debug information needed for test automation out of the applications binaries, so that the application size isnt increased while ensuring that the application can still be adequately tested and accessible beyond the UI. Its a good idea to run StripTDS as part of your automated build process, but I'll tell you more about this next time.
By the way, if you havent tried TestComplete 7 yet, you are missing a lot of great test automation capabilities. So, download TestComplete free and try it today. And let us know what you think about it your feedback is greatly appreciated, as always.