Sunday 13 April 2014

Script Naming convention and Coding standards

1.0         Purpose

An automated test script can be viewed as a full fledged program. Hence, like any other program in C, C++, Java etc, this script/program would undergo review (CWT), modifications etc. For a person to review or modify it, it’s obvious that the person understands the script thoroughly and there are no confusions. For that, the script should strictly follow standards for naming and coding.

This document explains the standards to be followed for-

  1. Script header
  2. Naming:
    1. Script
    2. Code variables
    3. Data table variables (column headings)
    4. Test objects (in the Object Repository)
    5. Report output file
  3. Coding:
    1. Commenting
    2. Indentation
    3. Decision statements (IF)
    4. Loops (WHILE, FOR etc)
    5. Database querying

2.0         Script Header

The test script header should have following details:

‘Name of the script:                               <Name of the script>
‘Name of the application and/or module:            <Name of the application for which the test is being written>
'Author:                                                 <Name & of the Author>
'User id:                                                <Author’s CEC id>
'Created on:                                          <Date (dd-mon-yyyy) on which this code was created>
'Purpose:                                              <Why this piece of code has been written>
'Input:                                                   <What are the input parameters (if any)>
'Output:                                                            <What are the output or return parameters (if any)?>
‘Pre-conditions:                                     <What are user accesses required, desktop/QTP settings, Test environment specifics etc>
'Modified:                                             <1. Date Modified, Logic modified>
'                                                           <2. Date Modified, Logic modified>
                                                            .
                                                            .                                                            .
Note: Each place that you modify the code, please write the number as in modified and then write the code.

3.0         Naming standards

Following are the naming standards for the various entities-

3.1         Script

The script name should be in the format TestXXX and should follow a Hungarian notation.
E.g. TestMaxlengthValidations

3.2         Code variables

The code variables should be named based on the data type as below-
Boolean            bln        blnFound
Byte                 byt       bytRasterData
Date (Time)       dtm      dtmStart
Double             dbl       dblTolerance
Error                 err        errOrderNum
Integer              int         intQuantity
Long                 lng        lngDistance
Object              obj       objCurrent
Single               sng       sngAverage
String               str        strFirstName

3.3         Data table variables (column headings)

Inputs:
If a data table field is being used to store an input for a form, it should be named as “dt_in_<corresponding test object name>”.
E.g. if the form field <Template> has a corresponding test object (in the OR) as <Template>, the data table field should be named as “dt_in_Template”.

Expected results:
If a data table field is being used to store an expected result, which may output as a field value, static text or message, it should be named as “dt_out_<corresponding test object or form field name>”.

3.4         Test objects (in the Object Repository)

The test objects in the object repository should preferably be named as the corresponding form field names/labels. The names should follow Hungarian notation w/o any space.

3.5         Report output file

The report output file (Excel workbook) should be named as “report_<test script name>”.
The individual sheets in the workbook corresponding to the test cycles should be named as “Test Cycle#<cycle number>”.
E.g. the report file for the test script “TestMaxlengthValidations” should be named as “report_TestMaxlengthValidations”.

4.0         Coding standards

4.1         Commenting

Put descriptive comments at appropriate places to achieve following objectives:
·         A clear understanding of the logic
·         Ease for a person to understand and modify the code

4.2         Indentation

Indent the code appropriately and logically to understand the code flow.

E.g.
For counter = start To end [Step step]
    [statements]
    
   For counter = start To end [Step step]
    [statements]
    [statements]
                Next
   
    [statements]
Next

4.3         Decision statements

The decision statements like “IF”, “CASE” should be coded with following format-
        IF
 
        If condition Then
                               [statements]
               [ElseIf condition-n Then
                               [elseifstatements]] . . .
               [Else
                               [elsestatements]]
    End If

        CASE

        Select Case testexpression
                  [Case expressionlist-n
                     [statements-n]] . . .
                  [Case Else expressionlist-n
                     [elsestatements-n]]
   End Select

4.4         Loops

The loop statements like “WHILE” should be coded with following format-
      Do [{While | Until} condition]
               [statements]
               [Exit Do]
               [statements]
Loop

4.5         Database querying

In a scenario, where database querying is involved, following steps should be followed-

‘Create connection object
Set connectionObject = CreateObject("ADODB.Connection")
‘Create recordset object
Set recordSet = CreateObject("ADODB.Recordset")
‘Connect to the database
connectionObject.Open ("DSN=TEST;UID=<user id>;PWD=<password>;")
‘Fetch records
              While not recordSet.eof
                        tagId = recordSet("ID")
                        DataTable.SetCurrentRow(intRecordSetCounter)
                        recordSet.MoveNext
            .
            .
            .
Wend

Automation Testing Questionnaire

1 What is your requirement/expectation from Functional Testing Automation? 
2 What percentage of the regression suite do you expect to get automated?
3 What is lacking in the present manual testing process you wish to complement/improve through functional testing automation?(highlight business expectation - for regression scenarios, expected business benefits)
4 What is the frequency of change of business rules of the Application (number of change requests/week or month)?
5 What is the frequency of change of UI of the Application (number of change requests/week or month)?
6 Do you have a manual regression test suite? If Yes:
a. What percentage of application functionality does it cover?
b. How many test cases are there?
c. How well described are the cases? Can a tester having no knowledge of your application execute these cases?
d. How long does it take to run 1 full cycle in terms of person days(8 hrs a day)?
e. Where are the test cases stored? (HPQC or equivalent test management tool, Word or Excel)
f. Can you share a sample test case suite with us?
7 How do you set the test environment? 
8 What are the requirements in terms of Hardware and Software? 
9 Where is the application hosted?
10 How will we access the application? (Over the internet, via a VPN connection, Via a citrix connection, installed locally)
11 Technology / Protocol
12 Any data encryption and / or compression while submitting request
13 Describe Application / Product functionality
14 Number of scenarios and/or transactions to be tested
15 No of Modules
16 Scripts per Module
17 No of Scenarios
18 Low Complexity
19 Medium Complexity
20 High Complexity
21 Any interfaces with external applications to be automated? Give details
22 Document upload / download?
23 Similar testing activities done in the past by any vendor, if so, describe problem statement and solution provided
24 Do you already have tools to support this? Do you have a prefered tool and if yes will you provide licenses?
25 Application Server(highlight RAM, service pack, patch etc)
26 Database Server(highlight RAM, service pack, patch etc)
27 Web Server(highlight RAM, service pack, patch etc)
28 Type of Web server
29 Type of Application server & Version (summarize deployment architecture)
30 Type of Database & Version(summarize deployment architecture)
31 Test Environment setup
- Do you have dedicated test environment hosted on separate LAN network
OR
- Is application available in hosted data center 
32 Any specific information to be captured in Test Report
33 Is application hosted on intranet or internet / Cloud? In case of Internet, pl state the network bandwidth