Getting all SpiraTeam project testcases using WebServices

Thursday, June 9, 2011 8:56:45 AM
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 4:17:40 PM
Avatar
re: mtha on Thursday, June 9, 2011 8:56:45 AM

//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 4:18:50 PM
Avatar
re: mtha on Thursday, June 9, 2011 8:56:45 AM

//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 12:28:47 PM
Avatar
re: inflectra.adam on 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 12:32:17 PM
Avatar
re: mtha on Friday, June 10, 2011
Where can one find a list of the property names to use with RemoteFilters?
Friday, June 10, 2011 1:19:07 PM
Avatar
re: mtha on 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 1:55:20 PM
Avatar
re: mtha on 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)?
Tuesday, July 26, 2011 4:37:43 PM
Avatar
re: DaisyDai on Thursday, July 21, 2011
You can download the necessary Java classes from: www.inflectra.com/Files/JavaSoap30Classes.zip
Statistics
  • Started: Thursday, June 9, 2011 8:56:45 AM
  • Last Reply: Tuesday, July 26, 2011 4:37:43 PM
  • Replies: 7
  • Views: 1524