Showing posts with label QC. Show all posts
Showing posts with label QC. Show all posts

Tuesday, August 18, 2009

Recursive search in vbscript.

It was this particular thing in vbscript which was lurring me from many days. I had written a small script for downloading Test Cases from Quality Center to Excel. QC 9.5 provides this as in built functionality but we had some old systems where in we had to pull all existing cases in Excel. The code was ready and I found that it needed exact path from QC logical folder structure to find all cases within it. There was a dire need to search within the given path to find all sub folders and test cases within them.

There was another requirement to replace one particular string from many script files stored on a server where quality center was installed. I had to replace all scripts which get saved on qc file system which had a particular string present in it. All test cases of type QUICK_TEST get saved with Script.mts file holding the actual textual part of script.

Here is a snippet to find particular file type (e.g.: Here i have searched for .mts file type as it was our requirement) within given folder and it searches in all sub folders present in it:

strDir = "D:\rohan\test"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objDir = objFSO.GetFolder(strDir)RecursiveFunc (objDir)

Sub RecursiveFunc(Dir_Passed)
For Each Item_File In Dir_Passed.Files
If LCase(Right(CStr(Item_File.Name), 3)) = "mts" Then
wscript.Echo Dir_Passed & "\" & Item_File.Name
End If
Next

For Each Item_Fldr In Dir_Passed.SubFolders
'wscript.Echo Item_Fldr.Name & " recursed"
RecursiveFunc (Item_Fldr)
Next
End Sub

Tuesday, March 31, 2009

QTP scripts bulk update.

We were caught in an extremely awkward situation few days back (I wonder why we always run into such situations :) ) wherein we upgraded our HP Quality Center and HP QTP to 10.0 which is their recent release. QTP 10.0 scripts were also in QC.
Before the upgrade took place we were running on QTP 9.2. We had a common vbscript for each Test Case in QC which used to call reusable actions saved at different location in QC. We also had associated those reusable actions. But after upgrade all our efforts were drained and we were left in a jeopardy where we could not even move back to 9.2 as much work had been done on QC front after the upgrade. The upgrade was done on live system without even checking on test systems whether it works or not. Management was to be blamed for it. Anyways, after the upgrade this association was lost and i was roped in to clear the debris and bring back the whole system on track.
After doing some research i came up with this unique update technique to get all the scripts updated automatically. I looked in all files which get saved when we save a QTP script and found that the 'Script.mts' file holds the actual text displayed when we open any script. I thought of updating the RunAction statement in this text with LoadAndRunAction statement. The parameters required for this new statement were different than from previous one which led to introduction of additional line of code which would call a new function and a additional vbs function. Our probelm was resolved and we were back to routine execution but the issue gave me nightmares.
Step 1:
Step 2:
Step 3:
Step 4:
Step 5:

Friday, January 2, 2009

Advanced scripting using OTA.

As we saw in OTA basics we were able to connect to any QC project in a matter of time. now once we have established connection with QC we can perform a variety of tasks. Before going for a long project let us divide it in smaller projects.
Think of normal everyday tasks in any software development organization using Quality Center for quality processes management. The day-to-day activities include daily builds, running basic tests, publishing reports.
We will take a large project called "AutoGenerator" which would perform following actions:
1) Verify build availability (assuming a build mail is received on build completion)
2) Kick start basic build verification tests (assuming the build is successful)
3) Execute the required tests (based on TestSets mentioned in QC)
4) Generate report (based on execution results)
5) Mail report

This is a long process which takes most of the time of any build engineer in any software organization and there are many dependencies due to which work may get delayed.
In simple words the project would work in minimizing these daily tasks by automating them.
The project would do wonders for both Dev and QA organizations as the test results would be available as the first thing in the morning and they can take approprite steps to cater it if anything goes wrong.

There are a lot of assumptions made while designing this project which are as follows:
1) The organization has a build process in place.
2) The build process also involves receival of mail using Outlook to intended recipents.
3) The organization uses QC for QA processes.
4) The organization uses QTP for automating their tests and scripts are saved in QC for execution.
5) Basic tests for verifying build are automated.
6) Reports are generated in Excel and published by mail.

Now let us divide this project in parts and have a look at one of them
Part 1 : Execute the required tests
Following is the code for same:
Set QCConnection = CreateObject("TDApiOle80.TDConnection")
QCConnection.InitConnectionEx
QCConnection.login ,
QCConnection.Connect ,
Set TestSetFact = QCConnection.TestSetFactory
Set tsTreeMgr = QCConnection.TestSetTreeManager
Set tSetFolder = tsTreeMgr.NodeByPath()
Set TestSetsList = tSetFolder.FindTestSets()
Set theTestSet = TestSetsList.Item(1)
Set gettestlist = theTestSet.TSTestFactory
Set TestSetlist = gettestlist.NewList("")
For Each gettest In TestSetlist
gettest.HostName =
gettest.Post
Next
Set TestSetlist = Nothing
Set Scheduler = theTestSet.StartExecution("")
Scheduler.Run
Set execStatus = Scheduler.ExecutionStatus
Dim RunFinished, ExecEventInfoObj, TestExecStatusObj
RunFinished = execStatus.Finished
While RunFinished = False
Sleep 300000
execStatus.RefreshExecStatusInfo "all", True
RunFinished = execStatus.Finished
Wend
Set execStatus = Nothing
Set Scheduler = Nothing
Set TestSetlist = Nothing
QCConnection.Logout
QCConnection.Disconnect
Set QCConnection = Nothing

The code above assumes that you are running the suit on some specific Host machine which will need to be replaced at the mentioned location.
We will have a look at other part in the next section.

Wednesday, November 26, 2008

Creating your own Dashboard for Mercury Quality Center in Excel using OTA.

There are very few things which amaze me... OTA is one of them.
It gives such flexibility and easy adaptibility that we can make use of same and create a whole new software for ourselves.
I would start listing a few things Ihave done using OTA in coming days. Comments are always welcome and Iwould be more than happy to help you guys out there.