-->

How to connect HP Quality Center using C# and ASP.

2019-07-09 07:45发布

问题:

I am looking to connect HP quality center using C# and ASP.net. Can someone please suggest me a way to connect it using .net web application. Also, do i need to do any installation on my server where my application is hosted?

Below is some java code i found, I want something like this

//Connect to QC    
    ITDConnection itdc= ClassFactory.createTDConnection();    
    System.out.println(itdc.connected());    
    itdc.initConnectionEx("http://QC.com/qcbin");    
    System.out.println(itdc.connected());    
    itdc.connectProjectEx("DomainA", "ProjectB", "UserID", "Password");    

回答1:

Well, there are two ways of doing this. These are using:

  1. OTA Client (Open Test Architecture)

    This is the traditional way of connecting with HP QC/ALM from a third party app. This API has been available for many years and is quite mature in terms of the interactions it allows with QC. However this API I believe is COM based and is fast becoming outdated. Therefore I wouldn't recommend using this to build extensive custom QC harnesses.

  2. REST API

    HP has started providing a REST API for QC in their last few version. The REST API in the latest version of QC (now known as HP ALM 11.5) seems to be quite mature. I'd say the main advantage of this would be speed and better interoperability as I believe REST is fast becoming one of the main stream standards for exposing remote services.

That was some background on your options. However to give some examples of the code in C#, see the following code snippet.

using TDAPIOLELib; // This is the QTP interop library 
private TDConnection qcConnection;

private string Connect()
{
    string status;
    status = "Initialising";

        qcConnection.InitConnectionEx("<QC URL>");
        qcConnection.ConnectProjectEx("<QC Domain>", "<QC Project>", "<LoginUserId>", "<UserPassword>");
        if (qcConnection.ProjectConnected)
        {
            status = "Connected";
        }
    return status;
}
public void GetTestsInTestSet(string testFolder, string testSetName)
{
    TDAPIOLELib.List tsTestList = new TDAPIOLELib.List();
    try
    {
        if (qcConnection.ProjectConnected)
        {
            TestSetFactory tSetFact = (TestSetFactory)qcConnection.TestSetFactory;
            TestSetTreeManager tsTreeMgr = (TestSetTreeManager)qcConnection.TestSetTreeManager;

            TestSetFolder tsFolder = (TestSetFolder)tsTreeMgr.get_NodeByPath(testFolder);

            List tsList = tsFolder.FindTestSets(testSetName, false, null);


            foreach (TestSet testSet in tsList)
            {
                TestSetFolder TSFolder = (TestSetFolder)testSet.TestSetFolder;
                TSTestFactory TSTestFactory = (TSTestFactory)testSet.TSTestFactory;
                tsTestList = TSTestFactory.NewList("");
            }

            foreach (TSTest test in tsTestList)
            {

                System.Diagnostics.Debug.Writeln(test[qcFrameworkTestIDFieldName]);
            }

        }
        else
        {
            Console.WriteLine("QC connection failed");
        }
    }
    catch (Exception e)
    {
        throw e;
    }    
}

Notes:

  1. To get the QC interop library, look for OTAClient.dll. This is downloaded onto your local machine once you first successfully access QC from you machine.
  2. HP ALM 11.50 - REST API Refrence: http://support.openview.hp.com/selfsolve/document/KM1413621/binary/ALM11.50_REST_API_Ref.html?searchIdentifier=4a65d813%3a140830b7b59%3a6cfa&resultType=document
  3. HP ALM 11.50 - OTA API Refrence: http://support.openview.hp.com/selfsolve/document/KM1413612/binary/ALM11.50_OpenTest_Architect_API_Ref.html?searchIdentifier=4a65d813%3a140830b7b59%3a6e9b&resultType=document
  4. Generally, I found it quite tedious to work with the OTA API in C#. Even from the reference guides it's quite difficult to some times work out some of the object types and casting. Using VB.Net may make it a little easier as I believe you wouldn't need to do so much casting. However, if I had to do it all over again, I would definitely consider the REST API first.

All the best.

S



回答2:

There is no implementation to execute test sets in HP ALM 11.50 - REST API Ref. So to execute test you need to use OTA API.