OnRoad Test Management

Welcome to OnRoad Test Management Sign in | Join | Help
in Search

Where can I keep the common code for my vapi-xp tests

Last post 02-05-2010 13:08 by Mahesh1283. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 02-04-2010 15:05

    Where can I keep the common code for my vapi-xp tests

    Hi,

    I have a bunch of vapi-xp tests which have the same exect code and are parametrized using user defined fields in QC. I would certainly not like to keep mutilple copies of this code. My question is where can i keep this common code? Is there a central common library somewhere on the QC side where I can store this stuff and just call them inside each vapi xp test? please advise.

    My Selenium Blog
    http://functionaltestautomation.blogspot.com/
    • Post Points: 20
  • 02-04-2010 15:07 In reply to

    • ilpo
    • Top 10 Contributor
      Male
    • Joined on 06-16-2006
    • Espoo, Finland
    • Points 51,934
    • Juvander Consulting

    Re: Where can I keep the common code for my vapi-xp tests

    Either inside or outside of QC. There are functions to download these common code moduels as attachments from test plan.

    //Ilpo

    • Post Points: 35
  • 02-04-2010 16:46 In reply to

    Re: Where can I keep the common code for my vapi-xp tests

    Is there a way to make VAPI-XP test template?

    My Selenium Blog
    http://functionaltestautomation.blogspot.com/
    • Post Points: 20
  • 02-04-2010 17:14 In reply to

    • ilpo
    • Top 10 Contributor
      Male
    • Joined on 06-16-2006
    • Espoo, Finland
    • Points 51,934
    • Juvander Consulting

    Re: Where can I keep the common code for my vapi-xp tests

    I think this is only available on QTP.

    //Ilpo

    • Post Points: 5
  • 02-04-2010 17:31 In reply to

    Re: Where can I keep the common code for my vapi-xp tests

    I am unable to follow are you saying that I should store the common function library in .vbs file and attach it to any one test as attachment and then programatically open/include this vbs file the current tests vapi-xp test script.

    My Selenium Blog
    http://functionaltestautomation.blogspot.com/
    • Post Points: 20
  • 02-04-2010 17:36 In reply to

    • ilpo
    • Top 10 Contributor
      Male
    • Joined on 06-16-2006
    • Espoo, Finland
    • Points 51,934
    • Juvander Consulting

    Re: Where can I keep the common code for my vapi-xp tests

    Yes

    • Post Points: 20
  • 02-05-2010 13:08 In reply to

    Re: Where can I keep the common code for my vapi-xp tests

    Hi again,

    This is what I have done

    1) I have attached a vbs file containing the code to a test. I am calling this test 'config'.

    2)Now in my vapi-xp test I am loading this attachment (vbs file attached in step 1) and then including the code within it so that it is accessible later in my test. I have posted the code I am using below. Now I believe I would have to copy paste this code (posted below) in every vapi-xp test in my project. Although this is more efficient than having multiple copies of the integration code in every test but still there is some repetion. Is this the best option i got or do you think I can reduce the repetition any further. 

    Thanks again for your help.

     

    '--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    ' config [VBScript]
    ' Created by Quality Center
    ' 04/02/2010 14:41:55
    ' ====================================================

    'I addedd this to be able to include vbs files in my code

    Private Sub IncludeFileAbs (ByVal FileName)
    Const ForReading = 1
    Dim fso: set fso = CreateObject("Scripting.FileSystemObject")
    Dim f: set f = fso.OpenTextFile(FileName,ForReading)
    Dim s: s = f.ReadAll()
    ExecuteGlobal s
    End Sub

    ' ----------------------------------------------------
    ' Main Test Function
    ' Debug - Boolean. Equals to false if running in [Test Mode] : reporting to Quality Center
    ' CurrentTestSet - [OTA COM Library].TestSet.
    ' CurrentTSTest - [OTA COM Library].TSTest.
    ' CurrentRun - [OTA COM Library].Run.
    ' ----------------------------------------------------
    Sub Test_Main(Debug, CurrentTestSet, CurrentTSTest, CurrentRun)
      ' *** VBScript Limitation ! ***
      ' "On Error Resume Next" statement suppresses run-time script errors.
      ' To handle run-time error in a right way, you need to put "If Err.Number <> 0 Then"
      ' after each line of code that can cause such a run-time error.
      On Error Resume Next

      ' clear output window
      TDOutput.Clear

      ' TODO: put your code here

        Set TestFact = TDConnection.TestFactory
        Set treeMng = TDConnection.TreeManager
        Set sourceFolder = treeMng.NodeByPath("Subject\Automation")
        Set testF = sourceFolder.testFactory
        Set testFilter = testF.Filter
        testFilter.Filter("TS_NAME") = "config"
        Set TestList = testF.NewList(testFilter.Text)
        set tst=TestList.Item(1)
        Set AttachFact = tst.Attachments
        Set theAttachCol = AttachFact.NewList("")
        Set theAttach = theAttachCol.Item(1)
        theAttach.Load True, ""

        'msgbox theAttach.FileName
        IncludeFileAbs (theAttach.FileName)
        msgbox abc

      If Not Debug Then
      End If
      ' handle run-time errors
      If Err.Number <> 0 Then
        TDOutput.Print "Run-time error [" & Err.Number & "] : " & Err.Description
        ' update execution status in "Test" mode
        If Not Debug Then
          CurrentRun.Status = "Failed"
          CurrentTSTest.Status = "Failed"
        End If
      End If
    End Sub

     

    'The content  of the attachment vbs file is as below

    '--------------------------------------------------------------------------

    Dim abc

    abc="bcd"

    '--------------------------------------------------------------------------

    My Selenium Blog
    http://functionaltestautomation.blogspot.com/
    • Post Points: 5
Page 1 of 1 (7 items)