Use C # To Call The QC (Quality Center) Interface

Source: Internet
Author: User

This article describes how to use the development tool C #. Net to call the QC interface to read and write the objects such as test cases in QC. The software involved in this article includes:

  1. Quality Center
  2. Visual Studio 2005

QC is a test management tool used by many test teams. Its functions can basically meet the requirements. However, sometimes we need to read and write data in QC for secondary development. For example, import test cases in batches and export the bug data for statistical analysis.

First, some client controls will be downloaded when you open QC. Make sure that the following file "C: /program files/common files/Mercury Interactive/Quality Center/otaclient. DLL, open vs2005, create a C # console program, and add com to reference "OTA com ".

The following code can be written to access the QC interface. The interface objects are all under the namespace "tdapiolelib. First, use tdconnection to connect to QC:

Tdconnection tdconn = new tdconnectionclass ();
Tdconn. initconnectionex (qc_serverurl );
Tdconn. login (qc_user, qc_password );
Tdconn. Connect (qc_domain, qc_proj );

To read the test case directory, you must first create a treemanager object:

Treemanager tree = tdconn. treemanager as treemanager;

Then read a directory node:

Subjectnode node = tree. get_nodebypath (qc_folder) as subjectnode;

To read the test case object, you must use the "testfactory" object, which is an attribute of subjectnode:

Testfactory testfac = node. testfactory as testfactory;

Then use this object to read the list of test cases:

List tests = testfac. newlist (null );

Use foreach to traverse all the case objects in this directory:

Foreach (test T in tests ){}

To read the steps in the use case, you only need to use the designstepfactory In the use case object.

The following describes how to write data using interfaces. The above subjectnode Node object is still used. It provides an additem method to add a new directory and returns the new directory object:

Systreenode res = node. addnode ("newnode ");

To add a Use Case, you still need to use the testfactory object:

Test res = testfac. additem (testname) as test;
Res. Post (); // submit changes and updates

Designstepfactory stepfac = res. designstepfactory as designstepfactory;
Designstep newstep = stepfac. additem (stepname) as designstep;

Do not forget to intercept exceptions in the Code and release the connection with QC. Otherwise, more connections will occur, affecting the normal operation of the server:

Tdconn. disconnectproject ();
Tdconn. logout ();
Tdconn. releaseconnection ();
Tdconn = NULL;

The code for reading and writing bug information is not described here. You can try it yourself.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.