Geeks With Blogs

News QTP and Stuff

Theo Moore Questions... Morphology? Longevity? Incept dates?
I am working on a tool to extract requirements from docs produced by our Business Analysts. It will then take the extracted requirements and put them in Quality Center as requirements. I thought this would be fairly straightforward, as the Requirements are handled in the same way that other objects types are.

The objects are created via factory objects implementing IBaseFactory. Calling the AddItem method returns an instance of the object, either a new one or one pre-existing. The AddItem method documentation says:

Passing NULL as the ItemData argument creates a virtual object, one that does not appear in the project database. After creating the item, use the relevant object properties to fill the object, then use the Post method to save the object in the database.

This is the recommended technique for creating most objects that will be saved in the database. Exceptions are noted where appropriate in the specific factory object descriptions.

You can also pass an ItemData argument identifying the item to be added. When this syntax is used, no check is performed on whether all required fields have been initialized. This is safe when the item is never going to be added to the database, as in populating a list for display.

Now, I am writing this in VB6 to avoid some issues with Interop, so passing a Null is very simple. The code looks something like this (some initialization left out for brevity):

Dim myReq as Req

Set myReq = myReqFactory.AddItem(Null)

with myReq
    .Name = "SomeRequirementname"
End With

And that should be it....but it isn't. I kept getting "Failed to Post Req" which is most likely returned by the IBaseField3 interface which most objects implement. So, why? I mean, I've checked everything, all looks good...what could be the problem? I checked the "specific factory object description" per the documentation, but there was no info on this, no gotchas pointed out.

Another tester/developer posted this suggesting that I try a .Net project using tried dice.

I dug very deeply into the bowels (yech) of Hp to find some documentation. I even found that "You have reached the end of the Internet. Turn Back" page from the TV commercial. I swear some ancient 286, on the network buried in a closet somewhere came on and spit out the answer:

Null doesn't work with Requirements. Use -1.

-1 <> NULL!!!!

Turns out that -1 refers to the Root folder of the requirements tree. The other object types (test, bug, etc) all assume if you don't specify a path that you want the root, but not the requirements object. For the requirements you must explicitly tell it -1. Is it in the documentation? Nope. So much for referring to the specific object description.

What a great way to waste 3/4 of a day at work!
I hate that API, I really, really do.....but at least I got it.... Posted on Thursday, July 24, 2008 2:45 PM | Back to top

Comments on this post: Quality Center: Adding Requirements via API

Comments are closed.
Comments have been closed on this topic.
Copyright © Theo Moore | Powered by: