Testing SOAP WebServices with RestAssured

Testing web services? With no UI? Isn’t that a Developers job? Well… No… Since 2010, there’s a free open source tool on the testing market which enables you to easily create web service requests and evaluation of responses. Nevertheless, it offers a cool Gherkin-style syntax which makes it even easier to understand and use. Since […]

by Boris Stoyanov

January 19, 2016

1 min read

2016 01 19 13 37 44 Untitled presentation Google Slides - Testing SOAP WebServices with RestAssured

Testing web services? With no UI? Isn’t that a Developers job?

Well… No…

Since 2010, there’s a free open source tool on the testing market which enables you to easily create web service requests and evaluation of responses. Nevertheless, it offers a cool Gherkin-style syntax which makes it even easier to understand and use.

Since it is a free tool then it is only skills that are required to use it. And that would be just basic Java programming knowledge.

Here’s a sample of what a simple RestAssured test would look like:

CreateInvoiceRequest request = new CreateInvoiceRequest();
@Test
public void testInvoiceCreation(){
given().request()
.body(request.setInvoiceNumber("someNumber").setInvoiceItem("someItem").done())

.when().post()

.then().statusCode(200)
.body(hasToString(containsString("<ns2:TotalRegistries>1</ns2:TotalRegistries>")))
.body(hasToString(containsString(request.getInvoiceNumber())));
}

And where outside of it, we have defined the request template which we’re going to use in CreateInvoiceRequest

Capture

Here are the results:

execution

That is just one scenario which creates an invoice. Note that the execution time is about 1.5 seconds.

Next stop integrating tests in the build process.

 

Experienced QA and Test Automation Developer. With background in different domains such as Web, Client server, desktop applications and development and QA tools. Expert in creating Test Automation Frameworks in using different platform, tools and programming languages.