Thursday, June 4, 2009

Dynamically Creating QTP Test Batch File/Test Suit

Let us consider that our test folders are ready...
now run this code over the main folder that includes all test folders...
It will create .mtb batch file for test...

you can even open the .mtb file with notepad & adjust the sequence of test..

Function TestsToTestSuit(TestDirPath)
filename=TestDirPath & "\ProjectTestSuit.mtb"
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Set objFolder = fso.GetFolder(TestDirPath)
set colSubfolders = objFolder.Subfolders
Dim myarray()
dim i
i=1
If fso.fileexists(filename) Then
fso.deletefile(filename)
End If
Set file= fso.CreateTextFile(filename, ForAppending, True)
file.Writeline("[Files]")
file.Writeline("NumberOfFiles=" & objFolder.Subfolders.count)

For Each objSubfolder in colSubfolders
ReDim preserve myarray(i)
If (objSubfolder.Name<>"Screenshots") Then
myarray(i)=objSubfolder.Name
file.Writeline("File" & i & "=" & TestDirPath & "\" & objSubfolder.Name & ";1 ")
i=i+1
else
i=i+1
End If
Next
file.close
DirectoryNameToArray=myarray
End Function


i have excluded "screenshots" folder from SVN Test script folder

1 comment:

Anonymous said...

function also returns a array "DirectoryNameToArray" of names of test folder