I’ve had several requests for more examples using the OTA API. This is a companion piece with the previous post about Executing Tests in Quality Center using the OTA API.
If you’re running tests outside of Quality Center, some are bound to fail. And if you have to write a defect in QC to associate with the test, why should you have to open it up just for that.
While I don’t currently have a access to a working copy of QC to test it, creating a bug is pretty straightforward.
Once you have a connection established
TDConnection connection = new TDConnection(); connection.InitConnectionEx(qcUrl); connection.ConnectProjectEx(qcDomain, qcProject, qcLoginName, qcPassword);
You can get the BugFactory and create a bug with AddItem()
BugFactory bugFactory = connection.BugFactory; Bug bug = bugFactory.AddItem(null);
AddItem() takes an object with data, but we can add the data manually
bug.Status = "New"; bug.Project = "QCIntegration"; bug.Summary = "Short description of the bug"; bug.DetectedBy = "Aaron Evans"; bug.AssignedTo = "Nobody"; bug.Priority = "Low";
Finally, when you’re done updating your bug, you call Post() to save it.
There are some tricks for adding attachments and associating a bug with a test run, but I won’t go into that now.