dokaspar
dokaspar

Reputation: 8634

Restoring the order of TestSuites from a Testlink XML-RPC response?

I would like to use the Testlink API to retrieve TestCases/TestSuites and display them in a report. They should be sorted in the same order as they appear in the Testlink 'Test Specification' (a folder-like structure that can be reordered by mouse drag-and-drop).

Each TestCase returned by the RPC-XML API consists of a parameter z that describes its position within a TestSuite. Reconstructing the order of TestCases is therefore possible. However, there is no analogous parameter for ordering TestSuites within a project. For example, the following two lines can be used to obtain the TestSuites from Testlink...

conn = new TestLinkAPIClient(testlinkKey, testlinkURL);
TestLinkAPIResults suites = conn.getTestSuitesForTestPlan(testplanID);

... but the result only contains information about their hierarchy (parent_id), no information about their order is available.

Result[0] = {id=6754, name=TestThree, parent_id=6752}
...
Result[8] = {id=22818, name=TestOne, parent_id=6754}
Result[9] = {id=22819, name=TestTwo, parent_id=6754}

Is is possible to somehow reconstruct the order from the XML-RPC response so that I can list the Testcases exactly as they appear in the 'Test Specification'?

Upvotes: 2

Views: 655

Answers (1)

Laura G
Laura G

Reputation: 165

You can use a kind of "cheating way" to get the order :

conn = new TestLinkAPIClient(testlinkKey, testlinkURL);
TestLinkAPIResults suites = conn.getTestSuitesForTestPlan(testplanID);
for(int i=0; i<suites.length;i++){
   List<Integer> id = new LinkedList();
   id.add(suites[i].getId());
   System.out.println("order for "+suites[i].getName()+" = "+conn.getTestSuitesById(id)[0].getOrder());
}

I personnally used the testlink java api https://jar-download.com/java-documentation-javadoc.php?a=testlink-java-api&g=br.eti.kinoshita&v=1.9.2-1 but I think yours is quite the same.

Hope it will help you

Upvotes: 1

Related Questions