Thursday, January 28, 2016

Test Post request via Soap UI

Currently Im working on a mobile based project and most of the communications are done with the server by using post requests.
So i started validating the server side requests and response.

Sample Post request will looks like : 

www.<DomainName>.com/API/Language/GetServiceRequestViewModel

Sample Get request will looks like : 

www.<DomainName>.com/API/Language/GetLanguageList


Post request also contain get and get request all so contain get. this is soo funny, LOL.

Configure the POST request.

Open SoupUI and select "New Rest Project" under file menu.



Click on a"OK" and user will get a screen as on the below image.



Click the play button and you dont get nothing,
Because this REST request need to have some parameters to be as inputs, in-order to get some valid output.

There are several ways of inputting parameters to a REST request (it depend on the security level of the REST call and the way developer develop it).

For the below sample test i will be passing data thru the body of the request.


Now change the "Method" type to "POST" next to the play button at the window.

Window should change as on the below image.



For this i need to pass "username" as the input.

There for locate the text box below the "Media type" and set the text as below.

{
    
    UserName:'demo@demo.com'

}




This is how to pass an input thru the body.


Change the media type to "application/json".(Because the response or the output is a json file.)

Now click the play button and you will see there will be some kind of god output will display at the right side of the screen.


That means we have successfully run the POST request with some kind of output.


Configure the a Test-case for a POST request.

Locate the newly created Post request and right click on it.
Select "Add to test case".




You should see a screen as on the below image with a new test suite node at your project.



Run the newly created test suite.
You should get a valid output at right side of the screen, 
That means the configuring of test suite is successfully finished.


Add assertions to a POST request.

Find the assertion tab as on the below image and click on it.

 Click on "Green color Plush" mark an add any kind of assertion.

There are considerable amount of assertions that you can use.
Most useful things are :
  1. Property contains.
  2. Invalid HTTP Status codes.
  3. Valid HTTP Status codes.