Top Coding Standards Interview Questions
1. Explain Rational Robots Coding Standards?
The standards are for all testers using the IDE of Rational Robot to develop their automated test scripts.
The mission is to reduce maintenance costs when it comes to changes. This is done by setting up rules on how to name variables, functions, scripts and libraries, where to place them and when to use them.
The standards do not provide any information about the use of frameworks, best practices, Rational Robot settings and version control. These are all provided in separated documents.
2. Explain Naming Convention in Local scope variables?
Description
Variables represent values that can be changed within a procedure or function. Local scope variables are placeholders that reside within a function- or a script-body.
Syntax:-
[Prefix]+[ShortDescription]
[Prefix] is a lowercase letter (either “n”, s”, “str”, “d” or “t” appropriate to the type it represents)
[ShortDescription] is a corresponding name of what the variable stands for.
If [ShortDescription] consists of more then one word they are all separated using a capital letter for each new word.
3. Explain Naming Convention in Module-level variables (member-vars)?
Description
If variables are placed outside a function body their scope will be different from a local scope variable, therefore we flag those variables with a prefix “m_” that is very common in object oriented languages even though SQABasic is not an object oriented programming language.
Syntax
“m_” + [Prefix]+[ShortDescription]
[Prefix] is a lowercase letter (either “n”, s”, “str”, “d” or “t” appropriate to the type it represents) [ShortDescription] is a corresponding name of what the variable stands for. If [ShortDescription] consists of more then one word these are all separated using a capital letter for each new word.
Examples
• m_nCountDatabaseRecords
• m_strLastname
• m_sPassword
4. Explain Naming Convention in Arrays?
Description
Arrays in many programming-languages usually represent a fixed list of values (e.g. a list of lastnames). However within SQABasic the size for an array can either be fixed or grow if the number of items in the list is not known during compilation of the source code.
Syntax
“a” + [Prefix]+[ShortDescription]
Letter “a” indicates that the variable is of type array. [Prefix] is a lowercase letter that represents the type of variables in the array. The rules for [Prefix] are the same as for “Local scope variables”.
Examples
• asPersonList
• anNumberList
5. Explain Naming Convention Globals?
Description
The values of global variables can be used and changed all over the project within all scripts and libraries. Though it is highly recommended to keep the number of global variables small. If global variables tend to be used in a specific project only it is advisable to keep those values in either a project specific library header or in a separate configuration file.
Syntax
“g” + [Prefix]+[ShortDescription]
Letter “g” indicates that the scope of the variable is global. [Prefix] is a lowercase letter that represents the type of the global variable. The rules for [Prefix] are the same as for “Local scope variables”.
Examples
• gnNumOfPersons
• gsPersonLastname
6. Explain Naming Convention Constants?
Description
Constants are “variables” that cannot be changed within a function- or script-body. The value will always be the same during script-execution.
Syntax
“AX_” + [PURPOSE] + {OPTIONAL}
If the constant name consists of more than one word those will be separated using an underscore.
Examples
• AX_AUT_VERSION
• AX_DEFAULT_URL
7. Explain Naming Convention Functions?
Description
Functions abstract a sequence of SQABasic code statemens in either a script-file (.REC) or a library-file (.SBL) and cover them with a reasonable name that is explanatory to others.
Syntax
[SOURCE]+”_”+[PerformedAction]+[Parameterlist]+” As ” + [ReturnValue]
[SOURCE] is an abbr. of the library name it is implemented at. [PerformedAction] consists of two words, an action(verb) and an object the action is performed against. [Parameterlist] is a sequence of placeholders the function is feeded with. [ReturnValue] is the value returned by the function
Examples
• UTIL_CountItemInString(sHaystrack$, sNeedle$) As Integer
• SERVICE_Start(sServiceName$) As Integer
• SERVICE_StopAllServices() As Integer
The function name must always correspond to what the function is actually doing. That is the script developer knows what the function is doing without the need to dig any deeper into its implementation. If the function name is called “NaviagteTo(“a-web-link”) it is expected that the function does only navigate to that specific web-link and not doing additional actions that is deletion and/or creation of any records in the DBMS.
8. Explain Naming Convention Scripts?
Description
A script within Rational Robot is a file that contains a sequence of SQABasic code. The extension of the file is always “.REC”.
Syntax
[FEATURE] + “_” + [FUNCTION] + “_” + {optional}
[FEATURE] is a capital letter string denoting the feature name [FUNCTION] is a capital letter string denoting the function {optional} means that the remaining characters preceded by an underscore will be optional and left to each person to define a sensible name which clearly identifies each of the test scripts
Example
• BILL_REP_Outputformat (refers to script Billing feature with report function)
• PART_INS_Assesor
• PART_UPD_Assessor
9. Explain Naming Convention Libraries?
Description
Common used functions are placed in libraries. These are located in the SQABas32 subdirectory of the Robot working directory. A library is divided into three files, a header (.SBH), an implementation file (.SBL) and the compiled version (.SBX). Libraries are not necessarily bound to an AUT or feature.
Syntax for implementation file
[ax]+[ShortName]+”sbl”
Syntax for header file
[ax]+[ShortName]+”sbh”
Examples
• axCommonUtilities.sbl
• axDBAccess.sbh
• axGuiMapper.sbl
10. Explain Naming Convention Verification points?
Description
In functional testing, you need to verify that the objects in the application-under-test look and work as designed from build to build. To accomplish this, you can establish verification points also known as checkpoints or the objects. Because verification points are not very flexible when it comes to changes in the AUT it is wise to prefer Robot’s
SQAGetProperty…- commands to verify whether expected behavior is met or not.
Syntax
[vp]+[FEATURE]+ [FUNCTION]
Examples
• vpAURA_ImageUploaded
• vpAURA_CaseInserted
11. Explain Functions Introduction?
Common used functions are placed within libraries in the SQABasic directory. Files ending with “.SBH” contain the public interface they provide to other libraries and scripts. Files ending with “SBL” contain the implementation of the public interface and private functions.
You use them by including them in your testscript or in another library. However, never ever include a .SBL-file into your script or library, instead include the header file only (.SBH) otherwise you run into cyclic redundancy problems and the compiled SBX file growths for nothing.
Example
GOOD:
‘$include “axCommon.sbh”
FORBIDDEN:
‘$include “axCommon.sbl”
12. What is Functions Indention?
Use tabs to bring some structure into your function body
if(nPos > 1) then
nRetrun = True
else
nRetrun = False
end if
13. Explain Functions Size?
A function body should fit within an A4-page (approx. two monitor-pages). If the code does not fit it is a candidate for more decoupling to smaller functions. The larger a function body the harder to read and maintain.
14. Explain Scripts and libraries Introduction?
Scripts
A script within Rational Robot is a file that contains a sequence of SQABasic code. The extension of the file is always “.REC”. Typically the script contains an automated testcase and contains the business-logic and also the testdata. Although it is generally recommended to shift testcase-logic and especially testdata to external sources such as CSV or Excel it is NOT designed to do so today because this technique requires an underlying sophisticated automated test framework that we do not have implemented at this level of automation yet.
Libraries
Common used functions are placed in libraries. These are located in the SQABas32 subdirectory of the Robot working directory. A library is divided into three files, a header (.SBH), an implementation file (.SBL) and the compiled version (.SBX). Libraries are not necessarily bound to an AUT or feature.
15. How to deal both scripts and libs in Scripts and libraries?
Although it is possible to chain scripts by using the “CallScript” command it is not recommended to use it (or even exhaust) too much unless successful script execution of the called script does not depend on the prior executed script or if the chain is not too long and if a script is preceded by an initiating script followed by a script that brings the AUT back into a defined state.
Functionality or a business-case that is used very often such as the login-operation should not be placed in a script but in a function library because scripts don’t allow for parameter passing, ie. a login-script is unable to be reused with different usernames and passwords.
All functions within libraries and/or scripts need explanatory headers where one describes the purpose of the function.
16. Size of Scripts and libraries?
Main script section (“Sub Main .. End Sub) and function bodies should fit within an A4-page (approx. two monitor-pages). If the code doesn’t fit it is a candidate to do more decoupling to separate small functions. The bigger a function body the harder to read and maintain.
17. Documentation Introduction
Documentation is done to provide others with information and ease maintenance. The best documentation is done in the headers (function and scripts) and directly in the code. Any useful thoughts ie a chosen algorithm or a solution to a specific problem should be documented in order to help others understand the script(s) and/or function(s).
18. Explain Documentation Libraries?
The documentation rules are almost exactly the same as for Scripts “Documenting scripts”. Although from a technical point of view it is feasible to place procedures in libraries it is not common to do that. Functions are a better alternative as they accept parameter passing.