Unable to retrieve testcase steps via SOAP

Thursday, February 13, 2014
Avatar
Hi,

i'm trying to create a custom export for our testcases in spiratest 4.0. However, when trying to retrieve the teststeps from a testcase using soap, I get a null value instead of the actual step.
Does anyone have a clue (or even better, a solution) on what's going wrong here?

Thank you!
Johan Laebens


I'm using the following code:


import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.Map;

import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;

import com.inflectra.spirateam.mylyn.core.internal.services.soap.ArrayOfRemoteTestCase;
import com.inflectra.spirateam.mylyn.core.internal.services.soap.IImportExport;
import com.inflectra.spirateam.mylyn.core.internal.services.soap.IImportExportConnectionAuthenticateServiceFaultMessageFaultFaultMessage;
import com.inflectra.spirateam.mylyn.core.internal.services.soap.IImportExportConnectionConnectToProjectServiceFaultMessageFaultFaultMessage;
import com.inflectra.spirateam.mylyn.core.internal.services.soap.IImportExportConnectionDisconnectServiceFaultMessageFaultFaultMessage;
import com.inflectra.spirateam.mylyn.core.internal.services.soap.IImportExportTestCaseRetrieveByFolderServiceFaultMessageFaultFaultMessage;
import com.inflectra.spirateam.mylyn.core.internal.services.soap.ImportExport;
import com.inflectra.spirateam.mylyn.core.internal.services.soap.RemoteTestCase;
import com.inflectra.spirateam.mylyn.core.internal.services.soap.RemoteTestStep;

public class SpiraTest {

    private static final String WEB_SERVICE_SUFFIX = "/Services/v4_0/ImportExport.svc"; //$NON-NLS-1$
    private static final String WEB_SERVICE_NAMESPACE = "{https://www.inflectra.com/SpiraTest/Services/v4.0/}ImportExport"; //$NON-NLS-1$
    private static final String WEB_SERVICE_NAMESPACE_DATA_OBJECTS = "http://schemas.datacontract.org/2004/07/Inflectra.SpiraTest.Web.Services.v4_0.DataObjects"; //$NON-NLS-1$


    /**
     * @param args
     * @throws MalformedURLException
     * @throws IImportExportConnectionAuthenticateServiceFaultMessageFaultFaultMessage
     */
    public static void main(String[] args) throws MalformedURLException, IImportExportConnectionAuthenticateServiceFaultMessageFaultFaultMessage {
        String baseUrl = "THE_CORRECT_URL";
        URL serviceUrl = new URL(baseUrl  + WEB_SERVICE_SUFFIX);
        ImportExport service = new ImportExport(serviceUrl, QName.valueOf(WEB_SERVICE_NAMESPACE));
        IImportExport soap = service.getBasicHttpBindingIImportExport();

        Map<String, Object> requestContext = ((BindingProvider)soap).getRequestContext();
        requestContext.put(BindingProvider.SESSION_MAINTAIN_PROPERTY,true);
        boolean success = soap.connectionAuthenticate("CORRECT_USERNAME", "CORRECT_PASSWORD");
       
        System.out.println(success); // returns true
       
        try {
            boolean connectedToProject = soap.connectionConnectToProject(18); // certain project which does exist
            System.out.println(connectedToProject);
           
            ArrayOfRemoteTestCase testcases = new ArrayOfRemoteTestCase();
            testcases = soap.testCaseRetrieveByFolder(8271); // folder exists
            List<RemoteTestCase> remoteTestcases = testcases.getRemoteTestCase();
            for (int i=0;i<remoteTestcases.size();i++)
            {
                System.out.println(i + "-- " + remoteTestcases.get(i).getName().getValue());
                JAXBElement<Integer> getTestCaseId = remoteTestcases.get(i).getTestCaseId();
                System.out.println(getTestCaseId.getValue()); // I can see all the testcasenames >> OK

                // This should work but somehow, the getTestSteps() is null
                List<RemoteTestStep> allesInEen = remoteTestcases.get(i).getTestSteps().getValue().getRemoteTestStep();
                for (int j=0;j<allesInEen.size();j++)
                {
                    System.out.println(">> " + allesInEen.get(j).getDescription());
                    System.out.println(">> " + allesInEen.get(j).getExpectedResult());
                    System.out.println(">> " + allesInEen.get(j).getSampleData());
                }
            }

           
        } catch (IImportExportTestCaseRetrieveByFolderServiceFaultMessageFaultFaultMessage e) {
            e.printStackTrace();
        } // http://spiratest.hq.ebit.be/SpiraTest/18/TestCase/8270.aspx
        catch (IImportExportConnectionConnectToProjectServiceFaultMessageFaultFaultMessage e) {
            e.printStackTrace();
        }
        finally
        {
            try {
                soap.connectionDisconnect();
            } catch (IImportExportConnectionDisconnectServiceFaultMessageFaultFaultMessage e) {
                e.printStackTrace();
            }
        }
    }
}



2 Replies
Thursday, February 13, 2014
Avatar
inflectra.sarahx
re: JLaebens Thursday, February 13, 2014
Hi Johan

For performance reasons we don't include the test steps when you retrieve a list of test cases by folder.

For each test case, you will need to call the web service again using the TestCase_RetrieveById(...) function to get the test case and its associated test steps.

Regards

Sarah.
Friday, February 14, 2014
Avatar
re: inflectra.sarahx Thursday, February 13, 2014
Hello,

Thanks for the info, I'm now indeed able (with the testcase ID) to retrieve it's steps!!

Johan

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, February 13, 2014
  • Last Reply: Friday, February 14, 2014
  • Replies: 2
  • Views: 8928