Once you have a WSDL imported and a project set up, it’s time to create your first TestCase. Please note that in soapUI there are many ways to do many flavors of Functional Testing; it can be used to validate very narrowly; each web service request and response on its own in Unit Testing, or widely; for a number of requests in sequence in Integration Testing. Further, you can add scripts using either Groovy or JavaScript that can enhance your tests in any way you want, for example interact with external systems or perform complex test-flow logic.
We will continue where we left off in the first "Getting Started" document. We just had created a project and imported the Amazon Web Service. In this tutorial we are going to learn three things:
- Create a test from a request in your WSDL
- Add an assertion to the test
- Run a test
1) Create a test from a request in your WSDL
- Expand the Web Service Interface by clicking on the plus sign next to it in the Navigator,
. Double click on the request . In the workspace you should now see the request editor. Please note that we’re using soapUI Pro and the form based view only is available from soapUI Pro.
- Select Add this request to TestCase
in the request editor.
Adding a Request to a TestCase will open the Create TestSuite dialog. - In the Create TestSuite dialog, enter a name for your TestSuite. Click OK.

- In the Create TestCase dialog, enter a name for your TestCase.

- In the following dialog Add Request to TestCase window, click OK.

soapUI will now generate a TestSuite and TestCase for you and the request will be added as a TestRequest. This is a copy of the request we have in the Interface. A TestCase Editor will also open with your new TestRequest.
2) Add an Assertion to the test
Now that we’ve created and run our first test, let’s add a validation of the response, what in soapUI is called an assertion. Start by closing down all windows you might have open in soapUI.
Info:
In soapUI an assertion is used for validating the response in your test. There are several assertions such as: Schema Compliance, Simple Contains, Simple Not Contains, SOAP Fault, Not SOAP Fault, SOAP Response, Response SLA, XPath Match, XQuery Match, Script Assertion, WS-Security Status, WS-Addressing Response Assertion and WS-Addressing Request Assertion
- Double Click on you Test Request. This will open The Request Editor.
- In the request editor, Click the Add an assertion to test request button.

- Select Schema Compliance from the drop down in the Select Assertion Dialog.

- In the Configure Schema Compliance Assertion Dialog, click OK, this will validate against the schema in the WSDL you imported earlier.

- Once you’ve added the assertion, run the request to validate the response by running the test and if the request and all assertions are successful, the SOAP Icon on the request tab should turn green, as should the SOAP Icon in the Navigator and the Assertion Header in Request Tab.

Tip:
You can see how many assertions you have in a test by looking at the assertions tab. The number of Assertions is written on the tab "Assertions (2)"
3) Run a test
We're getting pretty close to having a proper test, but let's just work on it some more in order to make it a proper test.
- If we examine what we've run before, we can see that we haven't actually sent any data. Let's create a test that has data input and that verifies the response. Let's start by adding another Assertion; click on the Assertions Tab
. This will reveal the Assertions Inspector which at the moment contains 2 assertions. Let's add a third by clicking the Add Assertion button
- We'll add the most simple test for checking the contents of a response, which is called the Contains Assertion. The Contains Assertions checks the entire response, including the XML for a string, as a tool, it's blunt but very easy to use.

- Let's add a search for "Madrid" in the response, since we don't know how the reponse will be formatted we'll tell soapUI to look ignore cases.

Save the Asssertion. - As you can see the assertion fails!

- This is to expect, we haven't created a proper reqest yet, as you can see above we're sending the PLaceName "?". Now let's send something that produces the expected result in the response; "Madrid". Add the text "Madrid" to the PlaceName element in the request.

The actual message looks like this:
Madrid
- Run the request by clicking the Run button. The assertion should now be Green since the PlaceName in the response contains the Text Madrid

Tip: If a Assertion fails, the Assertion tab will expand and show the Assertion Inspector to highlight the failed assertion. - Also try Running the TestCase from the TestCase Editor

- or from the TestSuite Editor




