background image
<< Porting Tests - Conditional compilation | Porting Tests - Supporting GUI-specific executables >>
Porting Tests - Conditionally loading include files
<< Porting Tests - Conditional compilation | Porting Tests - Supporting GUI-specific executables >>
270
User's Guide
13 P
ORTING
T
ESTS
TO
O
THER
GUI
S
Conditional compilation
Note Setting a GUI target affects which classes are listed in the
Library Browser.
3
To conditionalize code based on the value of constants you define, do the
following:
a
Click the Compiler Constants pushbutton in the Runtime Options
dialog.
The Compiler Constants dialog is displayed.
b
Define a constant and specify its value.
c
Use the constant in your code anywhere you can specify an
expression.
4
Click OK to close the Runtime Options dialog.
What happens
When the code is compiled:
·
Only code relevant to the GUI environments specified in the GUI Targets
field (plus all common code) will be compiled. If you don't list any GUI
specifiers in the GUI Targets field, all code will be compiled; at runtime,
code not relevant to the platform the application is running on will be
skipped.
·
The constants you have defined are evaluated and used to compile the
code. You can use this feature to conditionally load include files, as
described next.
Conditionally loading
include files
If you are testing different versions of an application, such as versions that
run on different platforms or versions in different languages, you probably
have different include files for the different versions. For example, if your
applications runs under different languages, you might have text strings that
appear in windows defined in different include files, one per language. You
want SilkTest to load the proper include file for the version of the application
you are currently testing.