You are on page 1of 25

CBOSS QA Automation

Document Number: ALL-CBOSS-GDLN-38815762 Version: 1.0-2 Status: Draft

QA Automation Coding Standards & Guidelines
Introduction..................................................................................... 43 1 Scope of this Document ............................................................. 43
1.1 Inclusions: ......................................................................................... 43 1.2 Exclusions:......................................................................................... 54

2

Coding Standards ...................................................................... 54
2.1 Variable Naming Convention ............................................................. 76
Input and Output Parameters ...........................................................................109 Input Parameters:............................................................................................. 109 Output Parameters: .......................................................................................... 109

2.2 Constant Naming Conventions ...................................................... 1110
2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 User defined....................................................................................... 1110 Pre-defined ........................................................................................ 1110 Color Constants .................................................................................. 1110 Date and Time Constants .................................................................... 1211 Date Format Constants ....................................................................... 1211 String Constants ................................................................................. 1312 Tristate Constants .............................................................................. 1413 VarType Constants ............................................................................. 1413

2.3 Function naming conventions........................................................ 1615 2.4 Code Commenting Conventions .................................................... 1615
i Revised 30-Jan-201308-Mar-2011
Document Number: ALL-CBOSS-GDLN-38815762 | Version: 1.0-2 | Status: Draft © 2013 Research In Motion Limited. RIM Confidential – Internal use only. Controlled document (except printed copies).

QA Automation Coding Standards & Guidelines

2.5 Business Process Test Naming Convention .................................... 1716 2.6 Business Components Naming Convention .................................... 1716 2.7 Formatting Your Code ................................................................... 1817

3

Headers................................................................................. 1817
3.1 Main Test Script ............................................................................ 1817 3.2 Sub / Function Procedure .............................................................. 1817

4 5 6 7 8

Control Statements ............................................................... 1918 General Rules and observations............................................. 2120 Data Table / Sheet formatting ............................................... 2221 Appendix – Object Naming Convention.................................. 2322 Naming Conventions for HP Service Test ................................ 2423
Formatted: Default Paragraph Font, Check spelling and grammar Formatted: Default Paragraph Font, Check spelling and grammar Formatted: Default Paragraph Font, Check spelling and grammar Formatted: Default Paragraph Font, Check spelling and grammar Formatted: Default Paragraph Font, Check spelling and grammar Formatted: Default Paragraph Font, Check spelling and grammar Formatted: Default Paragraph Font, Check spelling and grammar Formatted: Default Paragraph Font, Check spelling and grammar Formatted: Default Paragraph Font, Check spelling and grammar Formatted: Default Paragraph Font, Check spelling and grammar Formatted: Default Paragraph Font, Check spelling and grammar Formatted: Default Paragraph Font, Check spelling and grammar Formatted: Default Paragraph Font, Check spelling and grammar Formatted: Default Paragraph Font, Check spelling and grammar

Revision History ........................................................................... 2524 Introduction.......................................................................................3 1 Scope of this Document ...............................................................3
1.1 Inclusions: ........................................................................................... 3 1.2 Exclusions:........................................................................................... 4

2

Coding Standards ........................................................................ 4
2.1 Variable Naming Convention ............................................................... 6
Input and Output Parameters .............................................................................. 9 Input Parameters:................................................................................................ 9 Output Parameters: ............................................................................................. 9
ii

Revised 30-Jan-201308-Mar-2011
Document Number: ALL-CBOSS-GDLN-38815762 | Version: 1.0-2 | Status: Draft © 2013 Research In Motion Limited. RIM Confidential – Internal use only. Controlled document (except printed copies).

........................................ ... ...... 17 3.QA Automation Coding Standards & Guidelines Formatted Formatted Formatted Formatted Formatted Formatted Formatted Formatted Formatted Formatted Formatted Formatted Formatted Formatted Formatted ............ 13 2.........................................................................................5 2.......... ...2............ 22 Formatted ............................................ ............. Naming Conventions for HP Service Test ... 2...................................7 2...... 21 Formatted ............................................................................ 10 Color Constants ...................................... ................................... ......2.............................................................. 4 5 6 7 8 Control Statements ...............................................2.. 18 Formatted ... 11 String Constants ............................4 2.......................... 10 Date and Time Constants .................... .... .....2.6 Business Components Naming Convention ...............5 Business Process Test Naming Convention ........ ................................................... 15 2.................2..........................................3 Function naming conventions........................ 15 2......................... ....................................2 Constant Naming Conventions ...............................................................6 2...... 16 2........2.................. RIM Confidential – Internal use only........................... 20 Formatted ..... 16 3 Headers................................................ Appendix – Object Naming Convention......................... ..................... 16 2.......................................1 Main Test Script ...............4 Code Commenting Conventions .7 Formatting Your Code ............ 13 VarType Constants ....... Data Table / Sheet formatting ..................... Check spelling and grammar Revision History .......1 2............... 17 Formatted Formatted Formatted .................... ..2............................. 10 2... General Rules and observations..........................................0-2 | Status: Draft © 2013 Research In Motion Limited..........2 Sub / Function Procedure ...........2........... Controlled document (except printed copies)..................................................... ..... 17 3.............. 12 Tristate Constants .... ..... .......................................................................... 10 Pre-defined ........2 2...............................3 2. ............... .......... 22 Formatted: Default Paragraph Font..................................................... 24 iii Revised 30-Jan-201308-Mar-2011 Document Number: ALL-CBOSS-GDLN-38815762 | Version: 1..................... 11 Date Format Constants ....8 User defined................

Having said that. function and CONSTANT naming conventions Header and footer format for Main Scripts / Business Components. RIM Confidential – Internal use only. are not meant to be rigidly enforced without exception. Experience and informed judgment should be used whenever doubt exists. Controlled document (except printed copies). especially teams of developers working on the same application. rather than spend time trying to determine what particular format is appropriate for a given situation. It is expected that over time these practices will mature into coding standards used by all QTP developers. A consistent style:     Improves the readability. 1 Scope of this Document This document has been created for the use of creating all automated scripts across all applications within IT QA. another software engineering process with well-known benefits. Defined functions and Called Scripts 4 Revised 30-Jan-201308-Mar-2011 Document Number: ALL-CBOSS-GDLN-38815762 | Version: 1. and maintainability of scripts. we should strive to enhance this document to include the new scenario for future reference. The naming conventions have been based on industry standards. These standards however. once the guidelines are learned. a practice of regular code reviews can help enforce a consistent style. This document assumes the reader has a general understanding of Visual Basic Scripting Language (VBS).0-2 | Status: Draft © 2013 Research In Motion Limited.QA Automation Coding Standards & Guidelines Introduction The purpose of this document is to provide the CBOSS QA Performance & Automation (ITQA) team members who will be using Quick Test Professional (QTP) with a basic framework for creating automated scripts using Visual Basic Scripting Language (VBScript). by enabling developers to focus on the semantics of the code. when situations arise which are not covered by this document.1 Inclusions: Script naming conventions:   Variable. 1. The importance and benefits of a consistent coding style are well known. . Makes it easier to conduct code reviews. In turn. This document should be viewed as guidelines for using VBScript to code QTP automated scripts in a simple and understandable fashion. but have been streamlined for the IT QA environment. Consistency of coding style is more important than using a particular style. These practices have been documented to ensure that experience gained in the usage of VBScript is available to and used by the team. This document does not cover all possible situations. Saves developers time. Facilitates sharing of code among QTP developers.

Value is 0 for numeric variables or a zero-length string ("") for string variables. Controlled document (except printed copies). . VBScript Data Types VBScript has only one data type called a Variant. 5 Revised 30-Jan-201308-Mar-2011 Document Number: ALL-CBOSS-GDLN-38815762 | Version: 1. Because Variant is the only data type in VBScript. Variant Subtypes . it's also the data type returned by all functions in VBScript.QA Automation Coding Standards & Guidelines    Control Statements Code formatting Functions. readable. and unambiguous source code that is consistent with other language conventions and as intuitive as possible. variables and procedures Commenting Text formatting and indenting guidelines The main reason for using a consistent set of coding conventions is to standardize the structure and coding style of a VBScript or set of VBScripts so that you and others can easily read and understand the code. RIM Confidential – Internal use only. Contains either True or False.2 Exclusions:  Exception Handling / Recovery Scenarios 2 Coding Standards Coding conventions are based on industry standards that help you structure your VB Script. when to create a function 1. the use of common coding conventions will result in more precise.0-2 | Status: Draft © 2013 Research In Motion Limited. Variant intentionally contains no valid data. Subtype Empty Null Boolean Description Variant is uninitialized. Coding conventions included are:     Naming Conventions for Business Process Tests and Business Components Naming conventions for objects. depending on how it's used.The following table contains the list of Variant data subtypes. Overtime. A Variant is a special kind of data type that can contain different kinds of information.

203.94065645841247E-324 to 1. Contains a single-precision. Contains integer in the range -32.685.Returns a value indicating the subtype of a variable.QA Automation Coding Standards & Guidelines Byte Integer Currency Long Single Double Contains integer in the range 0 to 255.94065645841247E-324 for negative values.79769313486232E308 to -4.147.477. Contains a double-precision.483.147.477.401298E-45 for negative values. 100 to December 31.401298E-45 to 3. In addition. floating-point number in the range -3.79769313486232E308 for positive values. Date (Time) String Object Error You can use conversion functions to convert data from one subtype to another.647. Contains an error number. . VarType . (see chart below) Syntax: VarType(varname) Where varname can be any variable. Contains an object.5808 to 922.685. RIM Confidential – Internal use only. floating-point number in the range 1.337. Controlled document (except printed copies). Constant vbEmpty vbNull vbInteger vbLong vbSingle vbSingle vbCurrency Value 0 1 2 3 4 5 6 Description Uninitialized (default) Contains no valid data Integer subtype Long subtype Single subtype Double subtype Currency subtype 6 Revised 30-Jan-201308-Mar-2011 Document Number: ALL-CBOSS-GDLN-38815762 | Version: 1.5807. the VarType function returns information about how your data is stored within a Variant.402823E38 for positive values.768 to 32.767. 4. Contains a variable-length string that can be up to approximately 2 billion characters in length.402823E38 to 1.483.0-2 | Status: Draft © 2013 Research In Motion Limited. 9999.337.203. Contains a number that represents a date between January 1. 1.648 to 2. Contains integer in the range -2. -922.

To enhance readability and consistency. .0-2 | Status: Draft © 2013 Research In Motion Limited. In VBScript. For example: Dim strName. the Public statement. The body of a variable name should use mixed case and should be as descriptive as necessary and should be prefixed based on the object type prefix chart below. all variables are of type variant that can store different types of data.1 Variable Naming Convention Variable Declaration A variable is a way of referring to a memory location where you can store program information that may change during script execution. RIM Confidential – Internal use only. and the Private statement. lngPhone 7 Revised 30-Jan-201308-Mar-2011 Document Number: ALL-CBOSS-GDLN-38815762 | Version: 1. Controlled document (except printed copies). Scope and Lifetime of Variables You declare variables explicitly in your script using the Dim (or ReDim) statement. For example: Dim strName You declare multiple variables by separating each variable name with a comma. use variable prefix codes to indicate the primary type of data that they are designed to hold.QA Automation Coding Standards & Guidelines vbDate vbString vbObject vbError vbBoolean vbVariant vbDataObject vbDecimal vbByte vbArray 7 8 9 10 11 12 13 14 17 Date subtype String subtype Object Error subtype Boolean subtype Variant (used only for arrays of variant) Data access object Decimal subtype Byte subtype 8192 Array 2. strAddress.

QA Automation Coding Standards & Guidelines Lifetime of a variable is how long a variable exists in the script. Scope Procedure-level Script-level Prefix None S dblVelocity sblnCalcInProgress Example Rules to declare the Variable Names:      Must begin with an alphabetic character Cannot contain an embedded period Can contain an underscore (_) Max length is 255 characters Must be unique in the scope in which it is declared. Variable Scope Variables should always be defined with the smallest scope possible. VBScript variables can have the following scope. so does the value of being able to quickly differentiate the scope of variables.0-2 | Status: Draft © 2013 Research In Motion Limited. Note: You can have local variables of the same name in several different procedures because each is recognized only by the procedure in which it is declared. or Sub procedure Beginning of each script Visibility Visible in the procedure in which it is declared Visible in every procedure in the script Variable Scope Prefixes As script size grows. A one-letter scope prefix preceding the type prefix provides this. The lifetime of a script-level variable extends from the time it's declared until the time the script is finished the execution. a variable exists only as long as you are within that procedure. Local variables are temporary storage space when a procedure is executing. Scope Procedurelevel Script-level Where Variable Is Declared Event. Assigning Values to Variables 8 Revised 30-Jan-201308-Mar-2011 Document Number: ALL-CBOSS-GDLN-38815762 | Version: 1. At procedure level. Function. RIM Confidential – Internal use only. Controlled document (except printed copies). without unduly increasing the size of variable names. .

Dim strVar ' Declared variable. When you use the Option Explicit statement. As such it must be the first statement in the script. you must explicitly declare all variables using the Dim. Option Explicit ' Forces explicit variable declaration. for readability and consistency. Controlled document (except printed copies). Use Option Explicit to avoid incorrectly typing the name of an existing variable or to avoid confusion in code where the scope of the variable is not clear. The following example illustrates use of the Option Explicit statement. Subtype Boolean Byte Date (Time) Double Error Integer Long Object Single String Prefix Bln Byt Dtm Dbl Err Int Lng Obj Sng Str Example blnExist bytTeraData dtmStartTime dblTolerance errCustomerNum intLocate lngDistance objServerName sngCount strFirstName 9 Revised 30-Jan-201308-Mar-2011 Document Number: ALL-CBOSS-GDLN-38815762 | Version: 1. or ReDim statements. Use the following prefixes with descriptive names for variables in your QTP Scripts. Public. If you attempt to use an undeclared variable name or incorrectly typing the name of an existing variable. intValue = 10 ' Undeclared variable generates an error. Private.QA Automation Coding Standards & Guidelines Values are assigned to variables creating an expression as follows. RIM Confidential – Internal use only.0-2 | Status: Draft © 2013 Research In Motion Limited.This statement forces you to declare all the variables under it before using them in the script. the variable is on the left side of the expression and the value you want to assign to the variable is on the right. For example: strName = “Bob” Here strName is a Variable and “Bob” is the value of a variable. . Option Explicit statement: ‘Option Explicit’ . strVar = “Tomato” ' Declared variable does not generate any error. an error occurs.

The value passed could be used in the script during execution Output Parameters: Values could be return by the script during execution. ipblnStatus opintCount. Controlled document (except printed copies). Parameter Type Input Prefix Ip Example ipintCount. Input Parameters: Values could be passed to the defined parameters during execution.QA Automation Coding Standards & Guidelines Constant Note: Con conYearEnd  The descriptive name of the variable that follows after prefix should start with first letter capitalized. The parameters could be classified as input parameters and output parameters. The calling script for further execution could use the return value. ipstrName.0-2 | Status: Draft © 2013 Research In Motion Limited. To enhance readability and consistency and to differentiate between the types of the parameter use the following prefixes with descriptive names for the parameters declared in the code. RIM Confidential – Internal use only. opstrName. opblnStatus Output Op 10 Revised 30-Jan-201308-Mar-2011 Document Number: ALL-CBOSS-GDLN-38815762 | Version: 1. .  There should not be any spaces in the logical name that follows after the prefix Input and Output Parameters QTP gives the facility of passing the parameters to the components while executing the business scenarios. A standard prefix preceding the variable name would easily help in identifying the type of the parameter defined.

were implemented as variables and distinguished from other variables using all uppercase characters.1 Constant Naming Conventions User defined Earlier versions of VBScript had no mechanism for creating user-defined constants. Because these constants are already defined in VBScript.0-2 | Status: Draft © 2013 Research In Motion Limited.2. if used. 2. Simply use them in place of the values they represent. Following are the various categories of constants provided in VBScript.2. Constant VbBlack VbRed vbGreen vbYellow Value &h00 &hFF &hFF00 &hFFFF Description Black Red Green Yellow 11 Revised 30-Jan-201308-Mar-2011 Document Number: ALL-CBOSS-GDLN-38815762 | Version: 1. Constants. RIM Confidential – Internal use only. Constants provide a convenient way to use specific values without actually having to remember the value itself. . you don't need to explicitly declare them in your code. Multiple words were separated using the underscore (_) character. you may want to use an alternative naming scheme.3 Color Constants There are eight basic colors that can be used in scripting.2. Using constants also makes your code more maintainable should the value of any constant ever change.2 Pre-defined A number of pre-defined constants in VBScripts can be used in the code. For example: USER_LIST_MAX NEW_LINE While this is still an acceptable way to identify your constants. This convention uses a mixed-case format in which constant names have a "con" prefix. now that you can create true constants using the Const statement.QA Automation Coding Standards & Guidelines 2. Controlled document (except printed copies). For example: conYourOwnConstant 2.2 2.

5 Date Format Constants Defines constants used to format dates and times. Use the first full week of the vbFirstJan1 vbFirstFourDays 1 2 vbFirstFullWeek 3 2. Controlled document (except printed copies). Use the first week that has at least four days in the new year. Constant vbSunday vbMonday vbTuesday vbWednesday vbThursday vbFriday vbSaturday vbUseSystemDayOfWeek Value Description 1 2 3 4 5 6 7 0 Sunday Monday Tuesday Wednesday Thursday Friday Saturday Use the day of the week specified in your system settings for the first day of the week.2.0-2 | Status: Draft © 2013 Research In Motion Limited.2. Use the week in which January 1 occurs (default). RIM Confidential – Internal use only.4 Date and Time Constants Defines date and time constants used by various date and time functions. . 12 Revised 30-Jan-201308-Mar-2011 Document Number: ALL-CBOSS-GDLN-38815762 | Version: 1.QA Automation Coding Standards & Guidelines VbBlue vbMagenta VbCyan vbWhite &hFF0000 &hFF00FF &hFFFF00 &hFFFFFF Blue Magenta Cyan White 2.

6 String Constants Defines a variety of non-printable characters used in string manipulation. display time only. If there is no fractional part.QA Automation Coding Standards & Guidelines Constant vbGeneralDate Value Description 0 Display a date and/or time. For real numbers. Line feed. Display a date using the long date format specified in your computer's regional settings. Display a time using the short time format specified in your computer's regional settings. used for calling external procedures. Chr(13) & Chr(10) or Platform-specific newline character. not useful in Microsoft Windows. If there is no integer part.2. whatever is appropriate for Chr(10) the platform. vbNullChar vbNullString String having value 0 Not the same as a zero-length string (""). Carriage return–linefeed combination. Form feed. RIM Confidential – Internal use only. Display a time using the long time format specified in your computer's regional settings. Display a date using the short date format specified in your computer's regional settings. Constant vbCr vbCrLf vbFormFeed vbLf vbNewLine Value Chr(13) Chr(13) & Chr(10) Chr(12) Chr(10) Description Carriage return. Chr(0) Character having the value 0. vbLongDate 1 vbShortDate 2 vbLongTime 3 vbShortTime 4 2.0-2 | Status: Draft © 2013 Research In Motion Limited. Controlled document (except printed copies). . Date and time display is determined by your system settings. display only a date. 13 Revised 30-Jan-201308-Mar-2011 Document Number: ALL-CBOSS-GDLN-38815762 | Version: 1. display a date and time.

vbVerticalTab Chr(11) 2.2. not useful in Microsoft Windows.0-2 | Status: Draft © 2013 Research In Motion Limited.7 Tristate Constants Defines constants used with functions that format numbers.2. Constant vbEmpty vbNull vbInteger vbLong vbSingle vbSingle vbCurrency vbDate vbString Value Description 0 1 2 3 4 5 6 7 8 Uninitialized (default) Contains no valid data Integer subtype Long subtype Single subtype Double subtype Currency subtype Date subtype String subtype 14 Revised 30-Jan-201308-Mar-2011 Document Number: ALL-CBOSS-GDLN-38815762 | Version: 1.QA Automation Coding Standards & Guidelines vbTab Chr(9) Horizontal tab. True False 2. Vertical tab. Controlled document (except printed copies).8 VarType Constants Defines the various Variant subtypes. . Constant vbUseDefault vbTrue vbFalse Value -2 -1 0 Description Use default from computer's regional settings. RIM Confidential – Internal use only.

RIM Confidential – Internal use only.QA Automation Coding Standards & Guidelines vbObject vbError vbBoolean vbVariant 9 10 11 12 Object Error subtype Boolean subtype Variant (used only for arrays of variants) Data access object Decimal subtype Byte subtype vbDataObject 13 vbDecimal vbByte vbArray 14 17 8192 Array 15 Revised 30-Jan-201308-Mar-2011 Document Number: ALL-CBOSS-GDLN-38815762 | Version: 1. . Controlled document (except printed copies).0-2 | Status: Draft © 2013 Research In Motion Limited.

Remember the following points while writing the scripts:    Every important variable declaration should include an inline comment describing the use of the variable being declared. etc. pre/post conditions. 2. Int. Controlled document (except printed copies). erroneous comments. RIM Confidential – Internal use only. If there is no variable returned the function will need not have a prefix to represent a data type or class. based on the type of variable that is returned. etc. Return values for functions and variables that are changed by a procedure. A function is this case is a procedure with a script that does a specific amount of work in an effort to either calculate a result or perform an action. Although functions and subroutines are considered to be public by default. This description should not describe the implementation details (how it does it) because these often change over time. procedures. the function declaration should be explicitly defined as either “Public” or “Private”. Return values for functions and variables that are changed by a procedure. Arguments passed to a procedure.QA Automation Coding Standards & Guidelines 2. 16 Revised 30-Jan-201308-Mar-2011 Document Number: ALL-CBOSS-GDLN-38815762 | Version: 1. Variables.4 Code Commenting Conventions All the scripts.3 Function naming conventions A function should be treated the same as variables when it comes to declaring it as a Str. you should include an overview that describes the script. or worse. . At the beginning of your script. functions and procedures should be named clearly enough that inline comments are only needed for complex implementation details. functions should begin with a brief comment describing what they do. function should be described when their purpose is not obvious and when the procedure or function expects the arguments to be in a specific range. controls. should also be described at the beginning of each procedure. The code itself and any necessary inline comments describe the implementation. Arguments passed to a procedure should be described when their purpose is not obvious and when the procedure expects the arguments to be in a specific range. resulting in unnecessary comment maintenance work. This description should not describe how this could be implemented because these often change over time. assumptions. should also be described at the beginning of each procedure. especially through reference arguments. resulting in unnecessary comment maintenance work. All procedures should begin with a brief comment describing what they do.0-2 | Status: Draft © 2013 Research In Motion Limited. especially through reference arguments.

The following naming convention to be used for the Business Components: <Product Name / Lines of Business>_<Module>_<Business Component Name> <Product Name> . <Lines Oof Business> . <Module> .Describes about the business scenario for which the test is developed. . <Lines Ofof Business> .Describes the name of the module within the Product. Controlled document (except printed copies).Describes the name of the module within the Product. 17 Revised 30-Jan-201308-Mar-2011 Document Number: ALL-CBOSS-GDLN-38815762 | Version: 1. <Business Component Name> .QA Automation Coding Standards & Guidelines 2.is applicable to any Lines Of Business of the product for which automation in progress <Module> .Product Name refers to the name of the product for which the Business Process Tests are being created.Product Name refers to the name of the product for which the Business Components are being created.Indicates the appropriate Line of Business for which thisthat if the Business Component is applicable to any Lines of Business of the product for which automation in progress. <Business Scenario Name> . 2.Indicates the applicable appropriate Line of Business for which thisthat if the Business Process Test is applicable. RIM Confidential – Internal use only. The name of the Business Scenario should contain information to understand the purpose.5 Business Process Test Naming Convention All the Business Process Tests that are to be created by the Automation or SV&V team need to follow the common naming conventions while naming those tests.Describes the purpose of the business component. The naming convention to be followed to by Business Process Tests will be: <Product Name / Lines of Business>_<Module Name>_<Business Scenario Name> <Product Name> .0-2 | Status: Draft © 2013 Research In Motion Limited.6 Business Components Naming Convention The naming conventions for the business components should be similar with to the Business Process Tests naming conventions.

QA Automation Coding Standards & Guidelines 2. Controlled document (except printed copies). Identify the functionality/code. Add space / lines where necessary to improve readability. and create a function/procedure.2 Sub / Function Procedure Sub / Functions could be written to avoid the repetition of code. .7 Formatting Your Code Some pointers:    Standard nested blocks should be indented 1 tab (which is four spaces). 3 Headers 3. Script Header: ‘**************************************************************************** ‘ Script Name : <Name of the Script> ‘ Summary : Description of what the script does ‘ Author Name : <Script Creator> ‘ Created Date : <script creation date > ‘ Input Parameters : All Input Parameters for the script ‘ Output Parameters : All Output Parameters for the script ‘ Reviewed By : <<Reviewer of the script >> ‘ Modification Log : Script modification history '----------------------------------------------------------------------------------'' Sr. which is repetitive. which could be called at appropriate places instead of repeating the code each time ’**************************************************************************** ’ Sub / Function Name: <Sub / Function Procedure Name> ’ Author : <Script Creator> ’ Test Case : <All manual test cases encompassed in this script> ’ Description : Description of what the script does ’ Important Notes : <If any> ’ Functions Used : <All functions used within this script> ’ Input Parameters : <Function arguments> 18 Revised 30-Jan-201308-Mar-2011 Document Number: ALL-CBOSS-GDLN-38815762 | Version: 1.No. Date Modified by Reason for Modification Remarks '----------------------------------------------------------------------------------‘**************************************************************************** 3. The overview comments of a procedure should be indented one space. RIM Confidential – Internal use only.0-2 | Status: Draft © 2013 Research In Motion Limited.1 Main Test Script Having a brief description about the functionality covered in the script helps in understanding the script for a third person without actually going through the code.

its Function statement must include an empty set of parentheses. depending on the result. Usually the condition is an expression that uses a comparison operator to compare one value or variable with another. or expressions that are passed by a calling procedure). You can use conditional statements in your code to do this. In VBScript we have the following conditional statements:  If. A Function procedure is similar to a Sub procedure. Function procedure . Very often when you write code.0-2 | Status: Draft © 2013 Research In Motion Limited. but it’s a simple process to be executed . or expressions that are passed to it by a calling procedure). its Sub statement must include an empty set of parentheses (). A Function returns a value by assigning a value to its name in one or more statements of the procedure.is a series of VBScript statements.QA Automation Coding Standards & Guidelines ’ Modification Log : <<Script modification history>> ’----------------------------------------------------------------------------------’' Sr. Call ReportChkDB(Report. ChkDatabase Notice that the parentheses are omitted in the call when the Call statement is not used.Else .  When a status of a particular execution is required. make use of the procedure.Then. A Function procedure can take arguments (constants. variables..  When a status of a particular execution is not required. .. enclosed by Sub and End Sub statements that perform actions but don't return a value. variables.. Controlled document (except printed copies). to specify one or more statements to run.No.is a series of VBScript statements enclosed by the Function and End Function statements.Else statement is used to evaluate whether a condition is True or False and.Then.The If.. 4 Control Statements All control statements should be preceded by comments stating the purpose of the control flow and status of the control operation. You can call the Sub / Function procedures using Call statement. If a Function procedure has no arguments. RIM Confidential – Internal use only. Make appropriate use of functions and procedures. ChkDatabase) ReportChkDB Report.. Date Modified by Reason for Modification Remarks ’----------------------------------------------------------------------------------’**************************************************************************** Sub procedure . but can return a value... 19 Revised 30-Jan-201308-Mar-2011 Document Number: ALL-CBOSS-GDLN-38815762 | Version: 1. you want to perform different actions for different decisions.. If a Sub procedure has no arguments. The return type of a Function is always a Variant. make use of the function as it gives you the flexibility of returning the status. A Sub procedure can take arguments (constants.

... because of the lack of flexibility in While..The Select Case structure provides an alternative to If. 20 Revised 30-Jan-201308-Mar-2011 Document Number: ALL-CBOSS-GDLN-38815762 | Version: 1.Loops while a condition is True... Instead of repeating the statements a specified number of times.For Each.. Controlled document (except printed copies). You can use Do.Then..Loop instead..Loop statements to run a block of statements an indefinite number of times.Next loop.. ... A Select Case statement provides capability similar to the If. While..Then..0-2 | Status: Draft © 2013 Research In Motion Limited. a For Each..Next . RIM Confidential – Internal use only. The statements are repeated either while a condition is True or until a condition becomes True.Else statement.Next statements to run a block of statements a specific number of times..Else If for selectively executing one block of statements from among multiple blocks of statements.Next .Wend statement is provided in VBScript for those who are familiar with its usage.Next loop is similar to a For. Do..QA Automation Coding Standards & Guidelines      Select Case .. For Each.....Loops while or until a condition is True.. it is recommended that you use Do. This is especially helpful if you don't know how many elements are in a collection.You can use For. For loops.....Loop ... For. but it makes code more efficient and readable. However. The While.Wend.Wend . use a counter variable whose value is increased or decreased with each repetition of the loop...Next loop repeats a group of statements for each item in a collection of objects or for each element of an array..

Use Report Statements to report pass/fail conditions for each section in a script. Else if” statements. Standard. a GUI verification of a screen. Modularity is important. The tool is designed to help produce a higher quality product with fewer defects. Variables and constants should be scoped by function / procedure. tab based. both positive and negative. All conditional statements must be indented by one tab progressively depending on the nesting. or called script the easier it will be to maintain. displayed. it can be encapsulated as a function within the script and be called when required. Even if the creator finds the items self explanatory someone trying to debug it in a hurry may not.. Every important variable declaration should include an inline comment describing the use of the variable being declared. Document anything that needs documenting. module. Then. active. nested blocks should be used. . In unavoidable cases of multiple nesting..       Always use “Option Explicit” at the beginning of your script to enforce variable declaration. The more things that are put into a function.QA Automation Coding Standards & Guidelines 5 General Rules and observations Some general rules and observations:  Avoid using “On Error Resume Next” as it can lead to unpredictable results especially if you are evaluating a condition which you know is “false”. Add screenshot in the result file for the required validation during the execution Every manual step should be followed by automation step in test script           21 Revised 30-Jan-201308-Mar-2011 Document Number: ALL-CBOSS-GDLN-38815762 | Version: 1. The QTP automated scripts should not be created to simply go through the workflow to see if an application blows up. When creating a script scenario keep in mind that the goal is to verify expected results. rather than global. RIM Confidential – Internal use only. the status of a button or other icons / objects being either focused. Expected results can come in the form of expected static text in a message box.0-2 | Status: Draft © 2013 Research In Motion Limited. however the script is behaving like it is “true” and it’s all due to the fact that “On Error Resume Next” caused the script to skip the error and move onto the next line of code even though it was wrong. anything that can be used by more than one script should be either in a function library or a reusable action within a Test. enabled. disabled…etc Try to use “Select Case” whenever possible instead of multiple “If . Comments for self explanatory statements should be avoided There should not be any commented code lines in the script. Controlled document (except printed copies).

.0-2 | Status: Draft © 2013 Research In Motion Limited. 22 Revised 30-Jan-201308-Mar-2011 Document Number: ALL-CBOSS-GDLN-38815762 | Version: 1. Controlled document (except printed copies).QA Automation Coding Standards & Guidelines 6 Data Table / Sheet formatting Currently there are no guidelines in this area except for using common sense with regards to making the column names easy to read and understand. RIM Confidential – Internal use only.

Controlled document (except printed copies). .0-2 | Status: Draft © 2013 Research In Motion Limited. RIM Confidential – Internal use only.QA Automation Coding Standards & Guidelines 7 Appendix – Object Naming Convention Object type 3D Panel Animated button Arrays Check box Combo box Command button Common dialog Connection object Dictionary Drive Excel application object File Folder Frame Horizontal scroll bar Prefix pnl ani arr chk cbo cmd dlg cnx dic drv xls fle fld fra hsb Example pnlGroup aniMailBox arrKeys Object type Image Label Line Prefix img lbl lin lst btn sht Sld spn txt txs tbr win Example imgShow lblHelp linHorizontal lstCustomerCode s btnChoice rstQueryResults shtLayout sldRuler spnPages txtFirstName txsWrench tbrTools vsbVolume winTitle chkReadOnl List Box y cboGerman cmdClose cnxDBLink dicFiles drvHDD xlsForecast fleHandle fldRoot hsbSize Radio button Recordset object rst Slider Spin Text box TextStream (FSO) Tool Bar dlgFileExists Sheet Object Vertical scroll bar vsb fraLanguage Window 23 Revised 30-Jan-201308-Mar-2011 Document Number: ALL-CBOSS-GDLN-38815762 | Version: 1.

Controlled document (except printed copies). Specifically the “Script Transactions” section found in this document Performance Testing Team .0-2 | Status: Draft © 2013 Research In Motion Limited.doc The above naming convention document resides in this LiveLink folder: http://insite/livelink/llisapi. .QA Automation Coding Standards & Guidelines 8 Naming Conventions for HP Service Test The naming convention to be followed for scripts written in HP Service Test will be samewill follow as the VuGen naming convention and coding standard followed used by the CBOSS QA Performance Team. RIM Confidential – Internal use only.File Naming Conventions.dll?func=ll&objId=26650353&objAction=browse&sort=name 24 Revised 30-Jan-201308-Mar-2011 Document Number: ALL-CBOSS-GDLN-38815762 | Version: 1.

0-2 Date 08-Mar-2011 Revised by Marco Marsili Description Updated according to the new templates from go/templatecentral. .0 24-Mar-2009 Created the initial coding standards document Paul McNally.0-1 07-Mar-2011 Sid Pal & Automation Team Marco Marsili 1.QA Automation Coding Standards & Guidelines Revision History Version 1. Manager.0-2 | Status: Draft © 2013 Research In Motion Limited. Controlled document (except printed copies). Performance & Automation 25 Revised 30-Jan-201308-Mar-2011 Document Number: ALL-CBOSS-GDLN-38815762 | Version: 1. Title> <Full Name. Title> <Full Name. Updated document to include BPT and HP Service Test details Approved by <Full Name. RIM Confidential – Internal use only. Title> 1. Title> <Full Name.