How to fetch the path of TC in Test Plan using OTA
I have listed down the names of TC's in Excel. Now i need to pull those tc's from QC Test Plan to Test set in Test Lab. For that i need to find out what is the path of those tc in test plan. Can anyone please help me out in this.
So you want to get the path of a Test in Test Lab?
- Test names aren't unique, so you have to expect that you may find more than one test.
- If you find more than one test with the same name, the first path is returnedHow do you want to look up the path? (name, id, etc)
What method are you going to use to look up the paths (OTA I assume)
Are you using the OTA to get the TestCase names?I'm not too sure what TestLab has to do with this, your description is lacking so detail.
Last edited by ameehl; 07-03-2013 at 10:58 AM.
Reason: trying to fix the board not recognizing new lines
You said you were starting with a list of test case names. Are you 100% sure that your test case names are unique within the entire Test Plan module? QC requires test case names in the same folder to be unique, but you can have the same test case name used in different folders.
If you look in the OTA API reference materials at the Test object you will find various samples of code that you can piece together to get what you want. Look at the Test object for examples of finding a Test Case. Once you have found your Test Case, you can use the FullPath property of the Test object to get the full Test Plan path to the test case.
-Do you get the name of the test from the OTA already or do you get it from somewhere else?
-- If you do, just get the ID instead of the name
-- if you're not, this name is not unique, so how are you going to determine which path is correct?
I assume you want the solution handed to you, but I'm not going to be that nice
*** I have not tested this ***
// get a filter from the TestFactory
TDAPIOLELib.TestFactory fact = conn.TestFactory;
TDAPIOLELib.TDFilter filter = fact.Filter;
// filter the name of the test
filter["TS_NAME"] = "NAME OF TEST";
// list of all tests matching the name entered
TDAPIOLELib.List listOfTests = filter.NewList();
// pick the first test in the list
TDAPIOLELib.Test aTest = (TDAPIOLELib.Test)listOfTests;
// get the tree manager and find the parent folder path
TDAPIOLELib.TreeManager tm = conn.TreeManager;
TDAPIOLELib.SubjectNode sn = tm.NodeById[aTest["TS_SUBJECT"].NodeID];
// the path of the test
string path = sn.Path + "\\" + aTest.Name;