How to use SoapUI/Groovy to add Test Results to Quality Center Test Run?

How to use SoapUI/Groovy to add Test Results to Quality Center Test Run?



import org.codehaus.groovy.scriptom.*

def tstCaseName = "NAME_OF_TESTCASE"
tstCaseName = tstCaseName.replaceAll(/[ ]/) {  match ->
    "*"
}

Scriptom.inApartment
{
    //  Create an entry point for QC
    def tdc = new ActiveXObject ('TDApiOle80.TDConnection')

    //  Connect to QC, Login with Credentials, connect to Project
    tdc.InitConnectionEx('http://qc.example.com/qcbin')
    tdc.Login('USER_NAME', 'PASSWORD')
    tdc.Connect('DOMAIN_NAME','PROJECT_NAME')

    //  Find the set of tests in the Test Plan
    tsFolder = tdc.TestSetTreeManager.NodeByPath('Root\PATH\TO\TEST\CALENDAR\Spaces are allowed')
    tsList = tsFolder.FindTestSets('NAME_OF_TEST_CALENDAR')
    tsObject = tsList.Item(1)

    //  Get the list of TestCases in the Test Plan and filter it down to the one Test Case we are interested in
    TSTestFact = tsObject.TSTestFactory
    tstSetFilter = TSTestFact.Filter
    tstSetFilter.Filter["TS_NAME"] = '*' + tstCaseName
    TestSetTestsList = TSTestFact.NewList(tstSetFilter.Text)
    tsInstance = TestSetTestsList.Item(1)

    //  Create a new Test Run
    newRun= tsInstance.RunFactory.AddItem('Run_Auto')
    newRun.Status = 'Not Completed'
    newRun.Post()
    newRun.CopyDesignSteps()
    newRun.Post()

    //  Populate Auto Run Test step Data
    def tsStepData = new Object[3]
    tsStepData[0]='Auto Data'
    tsStepData[1]='Not Completed'
    tsStepData[2]='Results from Automated Test'
    //  Create new Test Step in the run with our Auto Run Data
    tsSteps = newRun.StepFactory.AddItem(tsStepData)
    tsSteps.Field['ST_ACTUAL'] = 'These are the actual results from my test!!'
    tsSteps.post()
}

Comments

Popular posts from this blog

How to build unlimited levels menu through PHP and MySQL

How to build a map of the frequency with which characters occur in a file in OCaml?

How to create timed pop-up windows using MVVM?