TestNG with RestAssured for multiple dynamic requests results issue

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

TestNG with RestAssured for multiple dynamic requests results issue

Emmadi Santhosh
Hi Team,

I have scenario like need to send multiple REST POST method input requests which is reading data dynamically from excel file, then take the testdata from excel file 

using dataprovider and validate with multiple input request response data with testdata provider results using rest assured API assert.

I am facing issue when i am trying to run with dynamic multiple requests and validate response with testdata using dataprovider.
Not able to display test results for multiple request validations.


Below is the sample code for dataprovider test data and actual input requests data.

@Test(dataProvider = "data",dataProviderClass = TVDataProvider.class)
public void productListConstructionLoan(String closingid, String closingname, String id, String name,
String quantity, String source, String endrid, String endrname,
String polcovname)
throws JSONException, InterruptedException, FileNotFoundException, IOException, ParseException {

//Read multiple intput request records from excel file here

for (String recordId : readAllRecords.keySet()) {
String inputRequest = readAllRecords.get(recordId);
RestAssured.given().body(inputRequest).contentType("application/json").cookies(cookie).when()
.post(prop.getProperty("productlistURL")).then().assertThat()
.body("productlist.closingcosts.closingid", hasItem(Integer.parseInt(closingid))).and().assertThat()
.body("productlist.closingcosts.closingname", hasItem(closingname)).and().assertThat()
.body("productlist.closingcosts.closingfees.id[0]", hasItem(Integer.parseInt(id))).and()
assertThat()
.body("productlist.policyproductgroup.policyproducts.policyname[0]", hasItem(polname)).and()
.assertThat()
.body("productlist.policyproductgroup.policyproducts.policycoveragename[0]", hasItem(polcovname));

}

}


Request is iterating multiple times but final results are showing only last request output result.

Regards,
Santhosh

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: TestNG with RestAssured for multiple dynamic requests results issue

Krishnan Mahadevan
Do you have a reproducible test that we can use to reproduce the problem ?

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Thu, Feb 22, 2018 at 11:56 AM, Emmadi Santhosh <[hidden email]> wrote:
Hi Team,

I have scenario like need to send multiple REST POST method input requests which is reading data dynamically from excel file, then take the testdata from excel file 

using dataprovider and validate with multiple input request response data with testdata provider results using rest assured API assert.

I am facing issue when i am trying to run with dynamic multiple requests and validate response with testdata using dataprovider.
Not able to display test results for multiple request validations.


Below is the sample code for dataprovider test data and actual input requests data.

@Test(dataProvider = "data",dataProviderClass = TVDataProvider.class)
public void productListConstructionLoan(String closingid, String closingname, String id, String name,
String quantity, String source, String endrid, String endrname,
String polcovname)
throws JSONException, InterruptedException, FileNotFoundException, IOException, ParseException {

//Read multiple intput request records from excel file here

for (String recordId : readAllRecords.keySet()) {
String inputRequest = readAllRecords.get(recordId);
RestAssured.given().body(inputRequest).contentType("application/json").cookies(cookie).when()
.post(prop.getProperty("productlistURL")).then().assertThat()
.body("productlist.closingcosts.closingid", hasItem(Integer.parseInt(closingid))).and().assertThat()
.body("productlist.closingcosts.closingname", hasItem(closingname)).and().assertThat()
.body("productlist.closingcosts.closingfees.id[0]", hasItem(Integer.parseInt(id))).and()
assertThat()
.body("productlist.policyproductgroup.policyproducts.policyname[0]", hasItem(polname)).and()
.assertThat()
.body("productlist.policyproductgroup.policyproducts.policycoveragename[0]", hasItem(polcovname));

}

}


Request is iterating multiple times but final results are showing only last request output result.

Regards,
Santhosh

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.