Yesterday I cleaned up and posted my example QCIntegration utility on GitHub.
While it works as a standalone tool, some people might not want to wade through the code to understand or modify it. So today, I’m going to try to explain how the OTA API works by recreating the steps as a blog post with explanation in a simple script.
I’ll start with an example using C# and then give an equivalent Python example. I’ll use the same scenario, updating test case results in QC, but if requested, I can also show how to get test steps from a test plan, or read & update defects in QC using the OTA library.
First, create a new project in Visual Studio (or SharpDevelop). You’ll need to add the OTAClient.dll as a reference. It is a COM library and contains the single interface TDConnection.
When searching for the library name it is called the “OTA COM Type Library”. The package is “TDApiOle80.” Since it is a COM library, it needs to use an interop for C#, but this is handled automatically by the IDE.
Now, let’s create a connection to your Quality Center server. You’ll need to know the URL of your QC Server and have valid login credentials with access to an existing Domain and Project.
Assuming you have quality center installed on your local machine (not a typical setup) you might have the following setup:
Note: I do not use this same password for my bank account
There are several ways to log in, but I’ll use the simplest here:
Now you need to find your test sets that need updated. I typically use folder structure that goes something like:
Project – Iteration – Component – Feature
It’s a bit convoluted but here’s the code to get a testSet:
The parameters for FindTestSets are a pattern to match, whether to match case, and a filter. Since I’m looking for a specific test set, I don’t bother with the other two parameters.
You could easily get a list of all test sets that haven’t been executed involving the recent updates feature by substituting this line:
Now we want to loop through the test set and build a collection of tests to update. Note that we might have more than one test set in the folder and one or more subfolders as well:
And finally, update each test case status:
Of course you might want to add your actual test results. If you have a dictionary of test names and statuses, you can simply do this:
That’s all for now. I’ll translate the example into Python tomorrow, but you’ll see it’s really quite straightforward.