Friday, October 21, 2011

QTP TFS Generic Test Integration

In Microsoft Visual Studio 2010 there is a Generic Test type that allows you to integrate with automation tools like QTP.  I have created a pretty simple solution that allows you to use your existing QTP automation scripts within the Microsoft Visual Studio testing framework and here's a sample below.  The key part of this solution is transforming HP's QTP format to Microsoft’s Generic Test format so that you can publish the results to TFS.  The added benefit of this integration is that you can also use TFS for bug tracking and more.  

  1. Download/Unzip QTP_TFSGenericTest folder to the C drive
  2. The contents of the C:\QTP_TFSGenericTest folder look like below
    • QTPResults folder - This will store the QTP result files
    • QTPTFSGenericSolution folder - This is the VS Solution with the Generic Test
    • TFSGenericTestResults folder - This will store the transformed TFS Generic Test results file
    • QTP.vbs - This is the main script that will execute QTP and transform the results file.
  3. Right-mouse click on the QTP.vbs file > select Edit
    • Replace the highlighted value below with the path of your QTP test
    • Save the QTP.vbs
  1. Navigate to C:\QTP_TFSGenericTest\QTPTFSGenericSolution
  1. Open the QTPTFSGenericSolution.sln(You will need Visual Studio 2010 to open this file)
  1. Double-click the QTPTFS.GenericTest
  1. The Generic Test will open and you will see the following below
  1. Navigate to the Test menu > Windows > Test View
  1. Click on the Run button as highlighted below
  1. You will then see the results of your Generic Test running a QTP script, in my case it Passed!

You can download the solution here QTP_TFSGenericTest.zip


Anna Russo
Application Lifecycle Management Consultant

20 comments:

  1. Anna, Which version of QTP is this written for?

    ReplyDelete
  2. Anna,i need the transform file for QTP 11 could you please provide

    ReplyDelete
  3. Hi Anna,

    Good to see this document and it is very useful, thanks a ton for this initiative.

    I am having nearly 5 years of experience in QTP and very new to this tool TFS

    Based on the request from our client we are planning to use TFS instead of QC.

    We don’t have any clue to execute QTP scripts from TFS and store the results in TFS, Kindly help me in regard with this.

    I have followed the steps mentioned above and QTP executed the test script successfully.

    After closing QTP I am getting the following error on the screen

    Windows Script Host
    Script:C:\QTP_TFSGenericTest\QTP.vbs
    Line:65
    Char:1
    Error:The stylesheet does not contain a document element. The stylesheet may be empty, or it may not be a well-formed XML document.
    Code:80004005
    Source:msxml3.dll

    Could you please tell me how to resolve this issue?I am using QTP 10.0 ,VS2010 Ultimate .

    Some other Queries related to this topic.

    1.Is it possible to checkin QTP script to TFS? I tried this but taking long time and VS going Not responding after some time.
    2.Is it possible to execute QTP script saved in TFS, if yes how can we do this?
    3.Right now all our scripts and supporting files are in QC,is it possible to export all these data to TFS?
    4.Can you please explain me how the supporting files work which you provided in the QTP_TFSGenericTest.zip,if I change the location to H: instead of C:,will that be a problem?
    5.Is it possible to execute the script in QC using the setup provided by you?
    6.How to attach the supporting vbs files to QTP residing in TFS?

    Thanks in Advance!!!!

    Regards,
    Renju

    ReplyDelete
  4. 1. Yes it is possible to check-in QTP scripts into TFS.
    2. Yes it is possible to execute QTP scripts by checking the files out.
    3. Yes it is possible for you to store your scripts and supporting files in TFS.
    4. All the supporting files are declared at the top of the file, so if you change the location there won't be any problems.
    5. I don't have access to QC, I created this using the Visual Studio framework to work with TFS.
    6. The workspace will define where the TFS files are stored locally, so you can change the vbs file paths to point to the TFS workspace.

    Anna

    ReplyDelete
    Replies
    1. hi,
      great info, quick questions
      1. is there a way to run multiple qtp scripts from a single generic test, in your great example only a single qtp script gets executed, what i want to know is if instead of providing a single qtp script to execute we provide a directory path with many scripts to execute, is this possible?

      2. i'm not sure how do you upload the results to display in TFS portal, after you run the generic test we need to see the pass or fail result in TFS.

      thanks,
      oscar.velasco

      Delete
    2. Hi Oscar,
      1. You could create multiple generic tests that each point to a script. Another way you could do this is in QTP by creating a master test that references other tests.
      2. You need to Publish your test results in order to see them in TFS.

      Anna

      Delete
  5. Hi Anna,

    Great Work, Thanks a lot for guiding us . Few questions

    1. Can you provide us the solution used for QTP 10.
    2. Even in the solution you have provided, how do we upload the results in TFS , and how do we publish the results stating - How many test cases passed and how many failed in TFS.

    Thanks
    AK

    ReplyDelete
  6. Hi Anna
    How can I run more than one QTP test with above solution?
    My requirement is like this:
    1. Application Login (QTP Script)
    2. Search on Application (Coded UI Script)
    3. Application Logout (QTP Script)
    It is very simple example and my requirement is combination of Coded UI and QTP Tests. It looks like for each QTP test I have to write separate QTP.VBS file from above solution.
    Thanks
    The Ghost

    ReplyDelete
  7. Hi Anna, Thanks alot for this great stuff. The only problem i am getting is an error message related to xml file format. Could you plz provide the desired xml file. The TFSGenericTestResults folder is empty in the zip file.

    I am getting the following error on the screen

    Windows Script Host
    Script:C:\QTP_TFSGenericTest\QTP.vbs
    Line:65
    Char:1
    Error:The stylesheet does not contain a document element. The stylesheet may be empty, or it may not be a well-formed XML document.
    Code:80004005
    Source:msxml3.dll

    ReplyDelete
    Replies
    1. Hi Rajender,

      This issue has been resolved with the latest version, please download the latest from here http://visualstudiogallery.msdn.microsoft.com/ef313348-8fd1-463b-9404-7472db99fda5

      Thanks,

      Anna

      Delete
  8. Hi Anna,

    On execution of the test from Visual studio, it says the test passed. But infact there is nothing getting executed, and QTP does not open for me.

    Can you please help.

    Chirag

    ReplyDelete
  9. Hi Chirag,

    You can test running the vbs from command line to see if QTP is opened.

    Thanks,

    Anna

    ReplyDelete
    Replies
    1. I ran the vbs from a command line, but still QTP do not open.

      I entered the following in the command prompt, Start /wait C:\QTP_TFSGenericTest\QTP.vbs.

      I apperciate your response.

      Delete
  10. Hi Anna,
    I didn't have any QTP related installation in my system and I have only the QTP scripts in .txt/.mts file format, will I be able to run these scripts using this.

    ReplyDelete
    Replies
    1. Hi Vanisree,

      It is required to install QTP on your system, because it is called directly from command line.

      Thanks,

      Anna

      Delete
  11. Hi Anna,
    I have both QTP and MTM environments in my system.
    Once i run the QTP scripts and stores the results in TFS server, i don't want to maintain QTP environment as it is licensed.Is it possible?

    My question is, after running the existing QTP scripts using this solution, can i remove the QTP environment so that i can create and maintain only MTM environment with MTM scripts.

    ReplyDelete
    Replies
    1. Hi Vanisree,

      This is an integration with QTP so you will need QTP installed. You should look into CodedUI tests for automation because it works directly with TFS.

      Hope that helps,

      Anna

      Delete
  12. Anna,

    What is the resolution for 2012?
    Is there a partner that offers an integrated solution?

    -MrHinsh

    ReplyDelete
  13. Hi Martin,

    Just open the QTP TFS Generic Test solution with VS 2012 Premium or Ultimate and the integration works the same.

    Thanks,

    Anna

    ReplyDelete