The online community for software testing & quality assurance professionals
 
 
Calendar   Today's Topics
Sponsors:




Lost Password?

Home
BetaSoft
Blogs
Jobs
Training
News
Links
Downloads



Testing Tools >> HP / Mercury TestDirector

Pages: 1
nskanth007
Newbie


Reged: 11/05/09
Posts: 1
how To update QC results from vbs
      #600069 - 11/05/09 02:51 AM

Can anyone tell how to update a test case as pass or fail in QC from vbs file. Not using QTP.

Post Extras: Print Post   Remind Me!   Notify Moderator  
pearce79
Newbie


Reged: 10/06/09
Posts: 21
Loc: London, UK
Re: how To update QC results from vbs [Re: nskanth007]
      #603335 - 11/27/09 06:20 AM

If you check the documentation (Help->Documentation Library) then I'm pretty sure you can do something with the QC API.

Or Google "Quality Center API" and I'm sure you'll find some useful examples.


Post Extras: Print Post   Remind Me!   Notify Moderator  
ttguy
Member


Reged: 01/28/09
Posts: 267
Loc: Canberra
Re: how To update QC results from vbs [Re: pearce79]
      #603577 - 11/30/09 03:44 PM

This example shows how to set the Run status on a Run.
You need to create a Run object first.
The Run object represents a Run of a Test Lab test.
I have included a function that creates a Run Object - GetTestRunOnTestSet

You also need FindTestSet function to get a test set object to pass to GetTestRunOnTestSet

Code:

dim RunStatus ,objRun
RunStatus = "Failed"
' RunStatus can be
'N/A
'No Run
'Not Completed
'Failed
'Passed


'
Set objRun = GetTestRunOnTestSet (...)' Custom Function - see below
objRun.Status = RunStatus
objRun.post





Code:
 

' GetTestRunOnTestSet
' finds a given test in a given testset in the Test Lab of QC project we are connected and generates a Run for this test returning a run object
'GetTestRunOnTestSet takes a TestSet object to indicate where to find the tests for creating the run

' you can pass in a pRunNamePrefix that will label you run names with this text

Public function GetTestRunOnTestSet (pConnection,pTestSet,pTestName, pRunNamePrefix)

' This function finds a test called <pTestName> living in a test set represented by a testSet object - <pTestSet>
' To get the test set object see the FindTestSet custom function below
'
' It produces a new Run for this test - the run is named automatically. The run it produces is returned by the function

' Because it returns an Object - don't forget to call the function using a Set statement.
' eg Set objRun = GetTestRunOnTestSet (...)


' One way to test if this function succeeded in Geting a test run is to do a TypeName()
' on the object returned from the GetTestRunOnTestSet call.
' If TypeName(objReturnedFromCall)="Nothing" then GetTestRunOnTestSet() call failed to create a test run

' It uses the Quality Center connection that we have allready created and connected and passed in as pConnection
' * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
' * Note: Include the Instance Number on the <pTestName> *
' * *
' * Eg look for "[1]TestName" rather than just "TestName" *
' * *
' * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Dim QCConnection
Dim TsTestFact
Dim tTest
Dim RnFact
Dim NwRun
Dim RnData(2)
Dim TestsInTestSet, TestSet, objTest, TestFound, PlanTest, tsetList , vItemKey
Dim vdirectory
Dim RunsInFactory, objRun
Dim vDummy
Set QCConnection = pConnection



Set TsTestFact = pTestSet.TSTestFactory ' get a TestSet Test Factory from our selected Test Set. This is a list of the Tests that are living in the TestSet
Set TestsInTestSet = TsTestFact.NewList("") ' TsTestFactory gives us a List of the Tests that are living in the TestSet. The list is a list of TSTest objects
TestFound = false
For Each objTest In TestsInTestSet ' for each TSTest in the TestSet we have found ...
If objTest.Name = pTestName Then ' ... look to see if we have the test we are looking for
' Need to include the instance number.
Set tTest = objTest ' tTest is the test in a test set that we were looking for
TestFound = true
'For example, "[1]Test 2" where [1] is the 1st instance.

Reporter.ReportEvent micPass , "Found Test", tTest.Name
Exit For
End If
Next
If TestFound Then



Set PlanTest = tTest.Test ' Also get an object reference to the associated Test in the TestPlan module


RnData(1) = QCConnection.UserName ' set up the User name on our test run object
Set RnFact = tTest.RunFactory ' get a runFactory for the Test-In-Test-set (ie testlab) we have found
Set NwRun = RnFact.AddItem(RnData) ' Create a new Run object using the run factory that belongs to our test
on error resume next ' trap case where rec is locked


NwRun.Name = pRunNamePrefix & RnFact.UniqueRunName ' create a name for our run automatically - with the specified prefix
' one time when running this I got RunError

If err.number<> 0 then
reporter.ReportEvent micWarning ,"GetTestRunOnTestSet", "Error When setting Run Name:" & err.number & " - " & Err.Description
err.clear
end if

set GetTestRunOnTestSet = NwRun ' make function return a Run Object



Set RnFact = Nothing
Set tTest = Nothing
Set TsTestFact = Nothing


else ' test not found

Reporter.ReportEvent micFail, "Test Not Found", "Could not find Test """ & pTestName & """ in Test Set: """ & pTestSet.TestSetFolder.Path & "\" & pTestSet.Name & """ on " & + QCUtil.QCConnection.ServerName + chr (13) +"Project: " + QCUtil.QCConnection.ProjectName + chr (13) + "Domain: " + QCUtil.QCConnection.DomainName
set GetTestRunOnTestSet = nothing ' make the return value nothing




end if




end function



FindTestSet function - for finding a test set in a given path

Code:

' FindTestSet - finds the test set called pTestSetName in the pDirectory of the Quality Center project represented by pConnection
' Returns True if the TestSet is found and returns the testSet found (as a TestSet object) in the pTestSet Parameter
' pDirectory should begin with "Root\"


Public Function FindTestSet (pConnection, pDirectory, pTestSetName, byref pTestSet)

Dim TestSetFound, TestSet , tsFolder, TestSetList,ttreeManager,tsetFact

If TypeName(pConnection) <> "Nothing" then' are connected to QC
if pConnection.ProjectName <>"" then ' are connected to a QC project
Set ttreeManager = pConnection.TestSetTreeManager
on error resume next ' trap case where pDirectory is not a valid path. In this case the following line returns a Invalid Node errro
Set tsFolder = ttreeManager.NodeByPath(pDirectory) ' Get the TestSetFolder object at the bottom of the pDirectory path
If err.number<> 0 then ' invalid path in pDirectory
Set ttreeManager =nothing
TestSetFound = FALSE
else

Set tsetFact = tsFolder.TestSetFactory ' Get a Factory from which we can produce a list of the test sets that live in the TestSetFolder we have found
Set TestSetList = tsetFact.NewList("") ' Get a list of the testsets that live in the TestSetFolder we have found
TestSetFound = FALSE
For Each TestSet In TestSetList ' loop through all the test sets in our list of test sets ...
If TestSet.Name = pTestSetName Then ' and look for our testset by name

Set pTestSet = TestSet ' pTestSet is the TestSet object we have found
TestSetFound =true
Exit for
End If
Next

Set ttreeManager =nothing
Set tsFolder = nothing
Set tsetFact = nothing
Set TestSetList =nothing

end if
else
TestSetFound =FALSE ' connected but not logged in a a user or not logged into a project
end if
else
TestSetFound =FALSE ' not connected to QC at all
end if
FindTestSet= TestSetFound
End Function



Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1



Extra information
0 registered and 4 anonymous users are browsing this forum.

Moderator:  AJ, jgottlieb, corklad, bpolitzer 

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Rating:
Topic views: 9268

Rate this topic

Jump to

Contact Us | Privacy statement SQAForums

Powered by UBB.threads™ 6.5.5