Star Quality 4Test Coding Guidlines

Revised: 08-29-05 blesuer


Capitalization:

  1. DataTypes are always all uppercase.
    Examples: STRING, INTEGER.
     
  2. UnderScores are used in DataTypes that are multiple words.
    Examples: MY_ENUM, MY_RECORD.
     
  3. Hungarian notation is used for all variable names. The first letter of a variable name is the first letter(s) of its type. The first letter for user defined types is ‘u’.
    Examples: sUserName, iLoopCounter, lsProperties, uEmployeeData.
     
  4. Method and Function names begin with an uppercase letter. Each Significant letter is capitalized.

Naming Conventions:

  1. Use the const SCRIPTROOT to reference the path to 4Test scripts. If multiple directories are used, make those references relative to SCRIPTROOT.
     
  2. The method used to invoke a window is called “Invoke”.
     
  3. The method used to close a window is called “Close”.
     
  4. The method used to accept a dialog is called “Accept”
     
  5. Method and Function symbols in the QA Organizer testplan should have the same name as their 4Test counterpart.

Coding Conventions:

  1. Functions and Methods that do not return values should be given the return type VOID.
     
  2. All methods and functions should end with a return statement even if it is VOID.
     
  3. All while loops that watch for a GUI event to terminate include a second expression/counter to prevent infinite loops.

    Example:
                      iLoop = 1
                              While !MyWindow.Exists && iLoop < 60
                              ...
                              iLoop++
     
  4. All switch statements have a default case, which may raise an error if no cases are matched.
     
  5. Use the 4Test style of the ‘for loop’ rather than the C-style.
     
  6. Place reusable functions in a file called myapp_funcs.inc.
     
  7. Pathnames are never hard-coded. Instead use the SCRIPTROOT environment variable.

    Example:  const DATA_DIR = SCRIPTROOT\data
     
  8. All “included files” are listed in a file called usefiles.inc. The main frame file for the application under test includes the statement ‘use “usefiles.inc”’
     
  9. Include a single space between a method name and its argument list. There is no space between the parenthesis and the first and last arguments.

    Example: VOID Invoke (STRING sPath)
     
  10. Non-trivial code is commented. Comments should also be included for any variable names that are not intuitively obvious.
     
  11. If the except part of a do .. except is empty, a comment should be included to explain the logic.
     
  12. he optional message parameter in the Verify statement is always included to better explain the error condition being generated.

Window Declaration Standards:

  1. Use multitags only where necessary. Always disable the feature from options/recorder.
     
  2. Objects are named as they are rendered in the application under test unless the name is ambiguous or long. In those cases, a clear, concise name can be substituted.
     
  3. Group child controls in a window declaration by object class. Within the class, order the controls as they appear on the screen from upper left to lower right.
     
  4. Move declarations for classes of controls that are not expected to be used to the bottom of the parent’s window declaration, e.g. StaticText.
     
  5. Members variables and are placed at the top of a window declaration after the tag and parent statements. Methods are placed next followed by declarations for child windows.
     
  6. Sort the declarations for container windows including DialogBox, ChildWin, BrowserChild alphabetically in the declarations include file.