Test Plan Module Script
I am trying to write code for following scenario and unsuccessfull so far.
In Test Plan module I have the test case in following folder structure:
FRUIT <- Parent Folder
APPLE <- Sub-Folder 1
RIPE <- Sub-Folder 2
Test Case 01_Test the ripe apple <- Test Case
I have created a new user field for Test module i.e. "Project". Now, with the Test Plan Module Script code in Test_MoveTo, I want to update the "Project" field in the Test Case: "Test Case 01_Test the ripe apple" with the top most parent folder name i.e. "FRUIT".
Please advice me here.
Show us the code you have written so far.
You are going to have to implement code using the Open Test Architecture API, I believe.
There is no field in the Test entity that stores the full folder path for the test.
There is a field that stores the ID of the folder in which the test directly resides. You will have to take that information, and then use that to figure out that folder's parent folder, and so on, to find the ultimate parent folder.
There are a couple of ways to accomplish this, but all of them require OTA code I think.
Maybe somebody else has a better idea.
(Opinions expressed in my postings are mine alone, and do not reflect the opinions of my employer.No warranties express or implied for any solution/suggestion posted.)
Sounds like you need to use SQL Analytics (which I am terrible at). Look up "connect by prior" or "connect by path"
Another thought process I had (not an exact answer but might help you navigate through the tree)
-- This will show the Upper Folder Name
-- Notice CF_ITEM_PATH will look like AAAAAA, AAAAAB, AAAAAC
WHERE LENGTH(CF_ITEM_PATH) = 6
-- This will show Sub Folder 1 Name
-- Notice CF_ITEM_PATH will look like AAAAAAAAA, AAAAAAAAB, AAAAAAAAC
WHERE LENGTH(CF_ITEM_PATH) = 9
-- This will show Sub Folder 2 Name
-- Notice CF_ITEM_PATH will look like AAAAAAAAAAAA, AAAAAAAABAAA, AAAAAAAACAAA
WHERE LENGTH(CF_ITEM_PATH) = 12
From here you can link the following to get your specific test.
CYCL_FOLD.CF_ITEM_ID TO CYCLE.CF_ITEM_ID
CYCLE.CY_CYCLE_ID TO TESTCYCL.TC_CYCLE_ID
TESTCYCL.TC_TEST_ID TO TEST.TS_TEST_ID
Once you have the specific test_id you can then update your "project" field