UFT 12.02 QTP integration with TFS

落爺英雄遲暮 提交于 2019-12-12 04:10:29

问题


I am looking for UFT and TFS integration (Run test from TFS like we did with HPQC) I search on google but no help . If anyone know how to do this please let me know steps.

Thanks


回答1:


You can use Generic Test to call QTP during the testing in TFS. Make sure QTP is installed on the test agent. See the code here for reference: QTP TFS Generic Test Integration.

One more link for reference: Executing remote QTP scripts via Test Agents and Test Controllers.




回答2:


Take a look at a solution from OpsHub.

More details:

Announcement: http://blogs.msdn.com/b/visualstudioalm/archive/2013/05/16/enabling-seamless-integration-with-team-foundation-server-microsoft-test-professional-and-hp-alm-with-opshub-v5-3.aspx

Video: http://opshub.com/ohrel/Resources/Videos/QTP_MTM_Video/QTP_MTM_Video.mp4

Case study: https://customers.microsoft.com/Pages/CustomerStory.aspx?recid=17218




回答3:


Take a look into this code:

import QTObjectModelLib dll from C:\Program Files (x86)\HP\Unified Functional Testing\bin location to your solution.

public void Fn_QTP()
{
qtApp.Launch(); 
qtApp.Visible = true; 
qtApp.Options.Run.RunMode = "Fast"; 
qtApp.Options.Run.StepExecutionDelay = 0; 
qtApp.Options.Run.ViewResults = false;  
qtApp.Test.Settings.Run.OnError = "Stop";
//iterate for all test cases under selected module
// oTestSuiteDict : this dictionary conatins all the testsuites from TFS which meant to be executed. 
//keys have their ID's 
foreach (var item in oTestSuiteDict.Keys)
{
    foreach (var TestCase in oTestSuiteDict[item].Keys)
    {
        Console.WriteLine("Executing TestCase  : {0}", TestCase);
        //update the XML file and upload in QTP
        //this XML file is used to provide the data to QTP as a environment variables.
        Fn_UpdateXMLFile(item, TestCase);

        //Open the test Case
        string scriptPath = @"path of script that will be opened in QTP (Action)";
        qtApp.Open(scriptPath, true, false);
        // Get a reference to the test object
        qtTest = qtApp.Test;  // Get reference to test object opened/created by application
        qtTest.Settings.Run.OnError = "NextStep"; 
        //check if the library is already associated.
        if (qtTest.Settings.Resources.Libraries.Find(@"library path") == 1)
        {
            qtTest.Settings.Resources.Libraries.RemoveAll();
        }
        qtTest.Settings.Resources.Libraries.Add(@"Library Path");
        //Console.WriteLine("Library is associated with Test");

        // Get a reference to the Results Object for  test results location
        QTObjectModelLib.RunResultsOptions qtRRO = new QTObjectModelLib.RunResultsOptions();

        // Run the test
        //creates and start the instance of Stopwatch just to track the time period of testcase execution.
        Stopwatch stopwatch = Stopwatch.StartNew(); 
        qtTest.Run(qtRRO, true, null);  // run the test
        stopwatch.Stop();
        string oTime = stopwatch.Elapsed.ToString();
        oTestCaseTime.Add(TestCase, oTime);
        string ostatus = qtTest.LastRunResults.Status;
        oResults.Add(TestCase, ostatus);
        qtTest.Close();  // Close the test
    }
}

System.Runtime.InteropServices.Marshal.FinalReleaseComObject(qtTest);  // Cleanly release COM object
qtTest = null; // set object to null
//break;
//qtApp.Quit();  // Quit QTP
GC.Collect();  // Garbage collect
GC.WaitForPendingFinalizers();  // Wait for GC
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(qtApp);  // Cleanly release COM Object
qtApp = null;  // set to null
}

// Fn_UpdateXMLFile : function to update environment variables for qtp //module name : the testsuite name(contains list of testcases); testcasename : testcases listed in modulename(test suite)

public void Fn_UpdateXMLFile(string modulename,string testcasename)
{
    string oPath = @"path of xml file";
    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.Load(oPath);
    XmlNodeList nodes = xmlDoc.SelectNodes("Environment/Variable/Value");
    nodes[0].InnerText = modulename;
    nodes[1].InnerText = testcasename;
    xmlDoc.Save(oPath);
}

//format of XML file :

<Environment>
  <Variable>
    <Name>ModuleName</Name>
    <Value>ToolsMenu</Value>
  </Variable>
  <Variable>
    <Name>""</Name>
    <Value>""</Value>
  </Variable>
</Environment>


来源:https://stackoverflow.com/questions/37339104/uft-12-02-qtp-integration-with-tfs

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!