Accessing Testopia XML-RPC Webservices using HTTP GET commands


A lot of our tests revolve around passing parameters to an executable and reading the output to determine if it is valid. Given the generic nature of this test procedure, it seems impractical for QA to maintain a set of test cases in a test tracker (Testopia in our case) and a separate set of automation scripts.

To alleviate the burden of synchronizing and updating automated test cases I set my sights on some sort of Web Service integration with Testopia. I'm starting small and working my way up.

This article will

  • Point you to the XML-RPC Webservice API docs for Testopia
  • Demonstrate how to Get all test cases associated with a Testplan via an HTTP GET

Notes:

 

Getting Started

Testopia exposes an API which makes it easy to pull information from the TestCase database. I've linked to a couple of places you can find out more specifics above in the Notes.

For me, XML-RPC was a little bit difficult to understand. I've done some work with Java web services and Windows Communication Foundation (WCF), so not having a WSDL was puzzling. There is http://www.xml-rpc.net/ if you want to use it in C#, but all I really wanted to do was pull a list of testcases. It seemed a bit inefficient to add a new DLL to my project for something so seemingly simple.

With Firebug's Net tab enabled I browsed to the Testopia Test Plan screen and selected one of the plans. This showed me how the http get requests behind the testplan query.

 

Use HTTP GET requests to pull data from an XML-RPC webservice

The name says it all. Rather than linking another library needlessly (I'm not a fan of adding complexity if I can avoid it), I just used what I found via Firebug to setup an HTTP GET request which queries data from the Testopia TestPlan XML-RPC webservice. Here's what the firebug window shows:

TestopiaOptions.png

Here's the complete URL I ended up with:

http://testopiaserver.domain.tld/bugzilla/tr_list_cases.cgi?plan_id=40&Bugzilla_login=automation@domain.tld&Bugzilla_password=SomePasswordHere&product_id=7&order=case_id&limit=10000&dir=ASC&current_tab=case&ctype=xml

Explanation of the URL components (There are user-customizable settings here):

  • http://testopiaserver.domain.tld/bugzilla/tr_list_cases.cgi is the fully qualified path to the webservice I'm hitting

  • ? (question mark) indicates that I'll be passing some parameters

  • plan_id=40 indicates that I want to look inside TestPlan # 40 (Testopia)

  • & (Ampersand) indicates that I'm passing additional parameters

  • Bugzilla_login=automation@domain.tld tells Bugzilla (which Testopia plugs into) which user I'm authenticating as.

  • &Bugzilla_password=SomePasswordHere tells Bugzilla my user's password

  • &product_id=7 lists the product we are working with (e.g. ACME Web console)
    • This entry is not required if you are just looking to pull test cases from a partituclar test plan. If you find you are getting no results when you change test plans, check to see if you have a product_id specified. You will either have to set it to the correct id or just not include it at all.

  • &order=case_id indicates some type of order. Not important for my tasks as I perform sorting in code
     
  • &limit=10000 This one is **important**: What is the max number of test cases you want returned? Enter that here. Or better, enter a higher number so you don't worry!
     
  • &dir=ASC I'm not sure what this one does
     
  • &current_tab=case This one might have something to do with internal representation of the Testopia dashboard. I'm not sure
     
  • &ctype=xml indicates that we'd like an XML response. you can change this to json if you prefer. :)

This will return an XML list of testcases which you can parse in code. I've got a less than elegant solution using XMLReader, but you may find something else more effective:

XMLReader reader = new XMLReader("http://testopiaserver.domain.tld/bugzilla/tr_list_cases.cgi?plan_id=40&Bugzilla_login=automation@domain.tld&Bugzilla_password=SomePasswordHere&product_id=7&order=case_id&limit=10000&dir=ASC&current_tab=case&ctype=xml");

while(reader.read())
{
  // Do something with the test case data received
  // Be sure to note that multiple test cases are in the response!
}

 

http://testopiaserver.domain.tld/bugzilla/tr_list_cases.cgi is the fully qualified path to the webservice I'm hitting

? (question mark) indicates that I'll be passing some parameters
plan_id=40 indicates that I want to look inside TestPlan # 40

& (Ampersand) indicates that I'm passing additional parameters

Bugzilla_login=automation@domain.tld tells Bugzilla (which Testopia plugs into) which user I'm authenticating as.

&Bugzilla_password=SomePasswordHere tells Bugzilla my user's password

&product_id=7 lists the product we are working with (e.g. ACME Web console)

&order=case_id indicates some type of order. Not important for my tasks as I perform sorting in code

&limit=10000 This one is important: What is the max number of test cases you want returned? Enter that here. Or better, enter a higher number so you don't worry!

&dir=ASC I'm not sure what this one does

&current_tab=case This one might have something to do with internal representation of the Testopia dashboard. I'm not sure

&ctype=xml indicates that we'd like an XML response. you can also plugin json if you prefer. :)