Friday, August 22, 2008

Automation Check List

Hey Dudes,

Most of us daily writes number of scripts and running them in batches for 100's of times. But we never think about the maintainability of the scripts.

It happens because most of the times, we wont get sufficient time because of build release schedules.

After developing a script, surely it will goes to a maintenance phase, but as per my experience i feel that script maintenance time does not exceed the script development time.

But here is a basic things(check lists) which we need to consider at script development to make it more easy to understand and maintainable.

This check list not only intended for the automation developer and also useful for the script reviewer.

Only script developer adherence to this check list not only enough,strict reviews should be happened with the experienced automation people and must educate the developers about the advantages of following the predefined guidelines.

Here are the some guidelines which i feel will be useful for the scripts developers:

1. Provide the script details in the header which conveys the purpose and author details.
2. Identify the precondition to be met prior to the script initiation.
3. Identify the assistance of third party tools(if required) to fulfill the functionality.
4. Provide detailed log messages for every functional point verification.
5. Verify the alternatives before going to use the check points, because it attracts maintenance.
6. Provide the appropriate comments for each block of code, to understands the code at later point of time and also helpful for others to understand our scripts.
7. Usage of appropriate error handling mechanisms either through programming language or built in tool feature to handle unexpected windows and run time errors.
8.Declare each and every variable at the beginning of the script and relevant comment about the type of data to be stored.
9. Release the resources acquired during the script execution time, for e.g when we set any object it occupies some memory, if it is not released after usage, the memory gets wasted.
10. Restore the application under test to the base state at the end of every script, such that it should not other scripts.
11. Clean the unnecessary files which are created during the execution time to store some intermediate results(like text files, csv files etc)
12. Identify the code components which can be used more often, or used repeatedly and make it as reusable.
13. If more than one developer working on automating the same features, while developing the reusable components make room for other to extend your reusable function, such that code redundancy can be reduced.
14. Never use any hard coded stuff in the scripts like paths, values etc. which are major road blocks in the maintenance, parameterize these values from a external source like configuration files.

Guidelines for Script Reviewer:

A script reviewer can use all the above mentioned points and including the below for the better maintainability.

1. Execute the script at least once.
2. Verify the conditional statements for false positives validation.
3. Verify the log messages and comments and header details most of the developers misses because of copy paste activity.
4. Verify the loops such that cant be executed for infinity
5. Verify the script doesn't break or produce any unexpected behavior when provided with different sets of data.

Thursday, July 31, 2008

Use of Windows Scripting In Test Automation

Here is my second post, Lets have a look at the importance and adavantage of Wscript(Windows Scripting) in Test Automation.

For every automation test script the pre-condition is to launch the application under test.

At times i observed that there will be conflicting while launching the application using the built in methods provided by the automation tools like QTP(Systemutil.Run) and TestComplete(TestedApps.Item.Run) etc.

The main reason for these type behaviors was the type libraries or add-ins associated with the tool conflicts with application, so application cant be launched in such type of scenarios. These type of behaviors i have observed especially with Java applications.

To overcome with this problem we need some mechanism to laucnh the applications out of automation tools scope.

Here is the Windows Scripting object provides with number of useful methods.

Syntax Call LaunchApplication(application path)

e.g. Call LaunchApplication("c:\Program Files\Internet Explorer\IEXPLORE.EXE")

Sample code to launch a application using Windows scripting shell object
----------------------------------------------------------------------
Sub LaunchApplication(strAppPath)

Dim objWso

Set objWso = CreateObject("WScript.Shell")
Call objWso.Run(strAppPath) (or)
'To launch from a command prompt
objWso.Run "cmd /k " & strAppPath

Set objWso = Nothing
End Sub

Saturday, July 19, 2008

Magic of temp in Automation

Hey,

All of earlier posts were not of my own writings, i just searched on net and extracted whatever i feel essential and useful for testers in automation.

Today is my turn to write my own experice in test automation.

Topic is use of temp folder/file in automation

At times we need to create temporary folders/files to store some intermediate data or content for computation during course of execution time.

Here is a simple scripts will be helpful in creating a folder or file as per your requirement.

Sysntax to use the below code: Call CreateTemp(folderorfilepath,folder/file)

E.g. To create a folder - Call CreateTemp("c:\temp\test\storetemp\","folder")
E.g. To create a file -Call CreateTemp("c:\temp\test\storetemp\storeresults.txt","file")

'******************************************************
' Name of the Function : CreateTemp
' Functionalty : To create a temporary folder/file
' Created By : Rajesh
' Created On : 19th July 08
' Input Parameter :
' 1. strPath: Path of the file system object (file/folder)
' 2. strFSO: Type of file system object. Possible values are FILE/FOLDER
' Return Value : NA
'********************************************************
Sub createtemp(strPath,strFSOType)
On Error Resume Next

Dim objFso 'ref object for file system

'Set referemce to file system object
Set objFSO = CreateObject("Scripting.FileSystemObject")

'Verify the prvided path is not empty
If strPath <> "" Then 'Fixes endless recursion in some instances when at lowest directory

'verify for the provided folder heirarchy in the file system and create if not exists
If Not objFSO.FolderExists(objFSO.GetParentFolderName(strPath)) then Call createtemp(objFSO.GetParentFolderName(strPath),"FOLDER")


'Verify the last node is a folder or file
If UCase(strFSOType) = "FOLDER" Then
objFSO.CreateFolder(strPath)
ElseIf UCase(strFSOType) = "FILE" Then

'If the file is already exists delete it and create new one
If objFSO.FileExists(strPath) Then
objFSO.DeleteFile strPath,True
End If

objFSO.CreateTextFile(strPath)
Exit Sub
End If
End If

Set objFso = Nothing
End Sub


Please provide me your comments

Friday, July 11, 2008

White Papers and Presentations On Test Automation

Hey,

Here is a large collection of Presentations and White Papers on test automation.

Its very rare to find these many articles at one place.

Papers and Presentations

Saturday, July 5, 2008

Friday, July 4, 2008