1

I am building web service testing framework. I am doing integration testing using soap ui (not pro).I have an ant script which runs my test runner. This is how my test runner looks like :

public class GatewayIntegrationTestRunner {

    JUnitReportCollector collector = new JUnitReportCollector();
    String path = "D:/DATA/Gateway/GWIntegrationTest_soapUI/GWIntegrationTestWksp/gateway-integration-test/src/META-INF/junit-style-test-report/html";

    @Test
    public void runGatewayIntegrationTests() throws Exception {

        SoapUITestCaseRunner  runner = new SoapUITestCaseRunner ();
        runner.setProjectFile("D:/DATA/Gateway/GWIntegrationTest_soapUI/GWIntTestStdProject/Liberate-Gateway-std-project-soapui-project.xml");

        runner.getTestCase();
        runner.setOutputFolder(path);
        runner.setJUnitReport(true);

        runner.run();
        runner.exportJUnitReports(collector, path, new WsdlProject());
        runner.printReport(0);
    }
}

My test runner loads my soap ui project xml and and runs tests spacified in the soap ui project. My requirement is that I want to specify different request parameters to the same api at different points. Earlier, when I was doing integration testing in Java, I had these request params specified in an xml file. How can I achieve this in soapui? I tried working with properties and property transfer in soapui but did not achieve much. Depending on the location where my application is deployed, I want to modify the request data, grabbing it may be from an xml file or properties file. How can I achieve it in soapui? Thanks in advance.

1 Answer 1

1

In SOAPUI when you defining your api try to do something like this:

let say you have resource API GET (https://your_host/Username)

you can change the Usename value at test case level by changing the above resource to

(https://your_host/${#TestCase#Username})

once you done that create a test case for the above resource and either (double click on the test case) or right click then show test editor.

In the window come up there is a button called (Setup Script) click on that then copy the following into the box:

def username = "John"
testRunner.testCase.setPropertyValue('Username',"${username}")

then click on the little green play sign above the box and then switch to (Properties) just next to (Setup Script) you should be able to see Username under Name and John under Value.

that is done for that test case with value of John as Username.

all you need to do now is to duplicate the test case (right click then clone TestCase) then change the value of username to something else e.g.

def username = "Chris"
testRunner.testCase.setPropertyValue('Username',"${username}")

Hope above helps and that is what you wanted.

7
  • Razh, Thanks for the answer. I do not get the first bit though which says, In SOAPUI when you defining your api try to do something like this: let say you have resource API GET (your_host/Username) you can change the Usename value at test case level by changing the above resource to (your_host/${#TestCase#Username}) Can you please explain me what you are suggesting? Thanks Dec 13, 2012 at 15:31
  • My Api has below paramaters <GetFaultDetailsInput> <businessID>CYN</businessID> <!--Optional:--> <serviceNo>9492001</serviceNo> Dec 13, 2012 at 15:34
  • I was assuming that you have created your test cases using SoapUI tool . The answer I have gave have to be done from SoapUI tool. The tool will generate and xml file and you can use that xml file for your need later.
    – justMe
    Dec 13, 2012 at 16:03
  • Razh, Yes I have generated my test cases using soap ui tool. So I have a test suite and test cases. However, I did not get just the starting bit of your answer. What exactly do I need changing at the test case level? Dec 17, 2012 at 10:19
  • Ok before you create your test suite and test cases you have created your resources. so the bit that you need to change is your resource path. Let say the current resource path is /account/accountID
    – justMe
    Dec 17, 2012 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.