Getting all SpiraTeam project testcases using WebServices

Thursday, June 9, 2011
Avatar
A.  I am new to webservice development.
B.  Does someone have an example on how I can use Webservices to get all of a projects test cases in the order they are listed in the project and get all the relevant test case/test step data including values from custom text and list boxes?

Thanks.
7 Replies
Thursday, June 9, 2011
Avatar
re: mtha Thursday, June 9, 2011

//Now lets test that we can retrieve a generic list of test cases and test runs from the sample project

spiraImportExport.Connection_Authenticate("fredbloggs", "fredbloggs");

spiraImportExport.Connection_ConnectToProject(1);

List<RemoteFilter> remoteFilters = new List<RemoteFilter>();

RemoteFilter remoteFilter = new RemoteFilter();

remoteFilter.PropertyName = "OwnerId";

remoteFilter.MultiValue = new MultiValueFilter();

remoteFilter.MultiValue.Values = new int[] { 2, 3 };

remoteFilters.Add(remoteFilter);

remoteFilter = new RemoteFilter();

remoteFilter.PropertyName = "ActiveYn";

remoteFilter.StringValue = "Y";

remoteFilters.Add(remoteFilter);

remoteFilter = new RemoteFilter();

remoteFilter.PropertyName = "ExecutionDate";

remoteFilter.DateRangeValue = new DateRange();

remoteFilter.DateRangeValue.StartDate = DateTime.Parse("12/1/2003");

remoteFilter.DateRangeValue.EndDate = DateTime.Parse("12/31/2003");

remoteFilters.Add(remoteFilter);

RemoteTestCase[] remoteTestCases = spiraImportExport.TestCase_Retrieve(remoteFilters.ToArray(), 1, 999999);

Thursday, June 9, 2011
Avatar
re: mtha Thursday, June 9, 2011

//Retrieve the first test case with its steps

RemoteTestCase remoteTestCase = spiraImportExport.TestCase_RetrieveById(testCaseId3);

Assert.AreEqual("Test Case 3", remoteTestCase.Name);

RemoteTestStep[] remoteTestSteps = remoteTestCase.TestSteps;

Assert.AreEqual(2, remoteTestSteps.Length, "Test Step Count 1");

Assert.AreEqual("Test Step 1", remoteTestSteps[0].Description);

Assert.AreEqual(1, remoteTestSteps[0].Position, "Position 1");

Assert.AreEqual("Test Step 2", remoteTestSteps[1].Description);

Assert.AreEqual(2, remoteTestSteps[1].Position, "Position 2");

Friday, June 10, 2011
Avatar
re: inflectra.david Thursday, June 9, 2011
Thank you!
I am trying it now.  I have now gotten past the "Object reference..." error with the sample code you provided but it is returning 0 test cases.

However, it appears you have wrote the sample code in .Net and I needed to converted to Java 1.6 which I am writing in IntelliJ :).  So I will play with it from here.  I have a suspicion it is the dates that are not correct. 

With this coding method here are some notes to share:

a.  The RemoteFilters array must be defined and initialized as RemoteFilter[] remoteFilter = new RemoteFilter[5] or else testCase_Retrieve will not accet the remoteFilter paramter.

b. With this version, the properties are treated as get and set value methods.

c.  Setting the date range for RemoteFilters uses a calendar type parameter, not date.

Just a note for those who might be doing this in Java.

Thanks.
Friday, June 10, 2011
Avatar
re: mtha Friday, June 10, 2011
Where can one find a list of the property names to use with RemoteFilters?
Friday, June 10, 2011
Avatar
re: mtha Friday, June 10, 2011
I got it!  If there is an interest I can post an example of how to code it using Java  and IntelliJ.

Thursday, July 21, 2011
Avatar
re: mtha Friday, June 10, 2011
I go over the https://www.inflectra.com/SpiraTeam/Downloads.aspx, and cannot find the library which can be added in my IDE.
Where can I found it(the jar file)?
Wednesday, December 6, 2017
Avatar
re: mtha Friday, June 10, 2011

Hello,

 

a code example will be appreciated :)

 

thank you

Spira Helps You Deliver Quality Software, Faster and With Lower Risk

And if you have any questions, please email or call us at +1 (202) 558-6885

 

Statistics
  • Started: Thursday, June 9, 2011
  • Last Reply: Saturday, November 5, 2022
  • Replies: 7
  • Views: 3769