3

我正在寻找使用 C# 和 ASP.net 连接 HP 质量中心。有人可以建议我使用.net Web 应用程序连接它的方法。另外,我是否需要在托管我的应用程序的服务器上进行任何安装?

下面是我找到的一些java代码,我想要这样的东西

//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");    
4

2 回答 2

6

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

于 2013-08-18T16:13:33.597 回答
0

在 HP ALM 11.50 - REST API Ref 中没有执行测试集的实现。因此,要执行测试,您需要使用 OTA API。

于 2015-02-03T13:47:15.977 回答