Part 2: Building API Automation Testing Framework in Rest Assured from from Scratch

preview_player
Показать описание
#apitesting #restassured #framework

@0:55 Continuing from part I
READING CREATED USER
@1:24 Create test method in "UserTests" class.
@2:37 Call a method from "UserEndPoints" class and pass other method in parameter in it using "This" keyword to use same username
@4:08 Store response in variable and log response in console
@4:38 Validate status code using assertions (correction @5:55)
@6:52 Execute the test
UPDATE USER
@9:15 Create test method.
@9:46 Copy the code from postUser test method into this method.
@10:35 Whichever the data to update we need to copy those Userpayload code.
@11:15 Rename the method to update the data and pass parameters in it using "This" keyword to use same username
@15:15 Log body in console
@15:54 Storing after update response in variable and validate status code using assertions (correction @19:16)
DELETE USER
@16:54 Create test method.
@17:35 Call a method from "UserEndPoints" class for same username using "This" keyword and store response in variable
@18:15 Validate status code using assertions
@23:14 Execute the test
DATA DRIVEN TEST
@24:32 Introduction
@26:19 Create a folder under same project and paste the excel sheet
@26:39 Opening excel sheet
@28:16 Paste the Excel utility file inside Utlities package
@35:25 Paste the Dataprovider file inside Utlities package
CREATE USER
@43:22 Create a class under "Test" package
@47:27 Create test method
@48:11 In test annotation, add priority, refer particular data provider and refer its class.
@50:45 Pass all variables related to user in parameters of test method
@53:36 Create object for POJO class
@54:09 Call all setter methods from POJO class and pass all variables related to user in parameters
@55:00 Call "Create user" method from "UserEndPoints" class, pass object for POJO class in parameter, store response in variable
and validate status code using assertion.
DELETE USER
@56:49 Create test method, in test annotation, add priority, refer particular data provider and refer its class.
@58:29 Pass username variable in parameter of test method
@58:51 Call "deleteuser" method from "UserEndPoints" class and pass username variable in parameter and store response in variable.
@59:24 Validate status code using assertions
@1:00:51 Execute the test
EXTENT REPORTS
@1:04:29 Paste the extent reports utility file inside Utlities package
@1:15:19 View reports
LOGGERS
@1:24:49 Create variable for logger class in test case class
@1:25:27 Initiate that variable in Beforeclass method for same class
@1:26:29 Adding logging messages in create user method and repeat for remaining methods.
@1:28:59 Execute the test
NOT WORKING WELL
@1:32:13 Call debug method in Beforeclass method
@1:32:32 Execute the test

Udemy Courses:
Manual Testing+Agile with Jira Tool
Selenium with Java+Cucumber
Selenium with Python & PyTest
Selenium with python using Robot framework
API Testing(Postman, RestAssured & SoapUI)
Web & API Automation using Cypress with Javascript
Playwright with Javascript
Jmeter-Performance Testing
SDET Essencials(Full Stack QA)
Appium-Mobile Automation Testing
Java Collections
Python Programming
Cucumber BDD Framework
Protractor with Javascript
Youtube Playlists:
Manual Testing & Agile
SQL
linux & Shell Scripting
Java
Selenium With Java+Cucumber
Python
Selenium With Python,Pytest&Behave
Selenium With Python Using Robert Framework
(Web&API Testing)
GraphQL
Рекомендации по теме
Комментарии
Автор

This is the best tutorial of restassured framework with reporting , not only on Youtube but on the entire internet as I have followed multiple rest assured framework tutorials. Thanks Pawan sir !

deepakrai
Автор

Thanks for giving us precious knowledge for free, Excellent explanation

salemabraham
Автор

You're Great Sir. We don't have any words praise your work

adityanarayan
Автор

I can't find the XLUtility and DataProviders files in the videos. Anyway, I created and executed it successfully.




package api.utilities;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

import
import
import
import
import
import

public class XLUtility {

public FileInputStream fi;
public FileOutputStream fo;
public XSSFWorkbook workbook;
public XSSFSheet sheet;
public XSSFRow row;
public XSSFCell cell;
public CellStyle style;
String path;

public XLUtility(String path)
{
this.path=path;
}

public int getRowCount(String sheetName) throws IOException
{
fi=new FileInputStream(path);
workbook=new XSSFWorkbook(fi);

int
workbook.close();
fi.close();
return rowcount;
}

public int getCellCount(String sheetName, int rownum) throws IOException
{
fi=new FileInputStream(path);
workbook=new XSSFWorkbook(fi);

row=sheet.getRow(rownum);
int
workbook.close();
fi.close();
return cellcount;
}

public String getCellData(String sheetName, int rownum, int colnum) throws IOException
{
fi=new FileInputStream(path);
workbook=new XSSFWorkbook(fi);

row=sheet.getRow(rownum);
cell=row.getCell(colnum);

DataFormatter formatter = new DataFormatter();
String data;
try {

}
catch(Exception e)
{
data="";
}
workbook.close();
fi.close();
return data;
}
public void setCellData(String sheetName, int rownum, int colnum, String data) throws IOException
{
File xlfile=new File(path);
if(!xlfile.exists())
{
workbook=new XSSFWorkbook();
fo=new FileOutputStream(path);
workbook.write(fo);
}
fi=new FileInputStream(path);
workbook=new XSSFWorkbook(fi);






sheet.createRow(rownum);
row=sheet.getRow(rownum);


cell.setCellValue(data);
fo=new FileOutputStream(path);
workbook.write(fo);
workbook.close();
fi.close();
fo.close();

}


}



package api.utilities;

import java.io.IOException;

import

public class Dataproviders {

@DataProvider(name="Data")
public String[][] getAllData() throws IOException
{
String
XLUtility xl=new XLUtility(path);

int
int colcount=xl.getCellCount("Sheet1", 1);

String apidata[][]=new String[rownum][colcount];

for(int i=1;i<=rownum;i++)
{
for(int j=0;j<colcount;j++)
{
apidata[i-1][j]=xl.getCellData("Sheet1", i, j);
}
}
return apidata;
}



public String[] getUserNames() throws IOException
{
String
XLUtility xl=new XLUtility(path);

int

String apidata[]=new String[rownum];
for(int i=1;i<=rownum;i++)
{
apidata[i-1]=xl.getCellData("Sheet1", i, 1);
}

return apidata;

}
}

Enjoy🥳

supriyabarai
Автор

My head is explode for the new knowledge xD Great tutorial :)

xXMrThomasXx
Автор

Thank you for the awesome and clear explanation. This tutorial made it easy for me to understand API testing☺

keerthisyna
Автор

@0:55 Continuing from part I

READING CREATED USER

@1:24 Create test method in "UserTests" class.
@2:37 Call a method from "UserEndPoints" class and pass other method in parameter in it using "This" keyword to use same username
@4:08 Store response in variable and log response in console
@4:38 Validate status code using assertions (correction @5:55)
@6:52 Execute the test

UPDATE USER
@9:15 Create test method.
@9:46 Copy the code from postUser test method into this method.
@10:35 Whichever the data to update we need to copy those Userpayload code.
@11:15 Rename the method to update the data and pass parameters in it using "This" keyword to use same username
@15:15 Log body in console
@15:54 Storing after update response in variable and validate status code using assertions (correction @19:16)

DELETE USER
@16:54 Create test method.
@17:35 Call a method from "UserEndPoints" class for same username using "This" keyword and store response in variable
@18:15 Validate status code using assertions
@23:14 Execute the test

DATA DRIVEN TEST
@24:32 Introduction
@26:19 Create a folder under same project and paste the excel sheet
@26:39 Opening excel sheet
@27:42 Update pom.xml with APACHE POI dependencies
@28:16 Paste the Excel utility file inside Utlities package
@35:25 Paste the Dataprovider file inside Utlities package

CREATE USER
@43:22 Create a class under "Test" package
@47:27 Create test method
@48:11 In test annotation, add priority, refer particular data provider and refer its class.
@50:45 Pass all variables related to user in parameters of test method
@53:36 Create object for POJO class
@54:09 Call all setter methods from POJO class and pass all variables related to user in parameters
@55:00 Call "Create user" method from "UserEndPoints" class, pass object for POJO class in parameter, store response in variable
and validate status code using assertion.

DELETE USER
@56:49 Create test method, in test annotation, add priority, refer particular data provider and refer its class.
@58:29 Pass username variable in parameter of test method
@58:51 Call "deleteuser" method from "UserEndPoints" class and pass username variable in parameter and store response in variable.
@59:24 Validate status code using assertions
@1:00:51 Execute the test

EXTENT REPORTS
@1:04:15 Update pom.xml with extent reports dependency
@1:04:29 Paste the extent reports utility file inside Utlities package
@1:11:52 Create testng.xml from Test package
@1:12:40 Disable data driven testcase in testng.xml
@1:13:20 Add extent reports tag inside testng.xml
@1:14:52 Execute testng.xml
@1:15:19 View reports

LOGGERS
@1:20:23 Add Apache log4j dependencies in pom.xml and update the project
@1:22:20 paste "log4j2.xml" in src/test/resources
@1:24:49 Create variable for logger class in test case class
@1:25:27 Initiate that variable in Beforeclass method for same class
@1:26:29 Adding logging messages in create user method and repeat for remaining methods.
@1:28:59 Execute the test

NOT WORKING WELL
@1:29:57 Change log levels in "log4j2.xml" for debug logs
@1:32:13 Call debug method in Beforeclass method
@1:32:32 Execute the test

ksdnsdkumar
Автор

Sir you are giving best knowledge free of cost. Thanks its so much useful, could u please add the extentReporter class and log4j.xml files here?

jqjgfpu
Автор

Thank you Mr Pavan, excellent as usual!!!

amember
Автор

Hello Sir, Thank you for creating such a wonderful course. Can I get this project code to understand it in a more better way ?

archanakulkarni
Автор

In POST request test data is not updated, It shows previous data only. Guys any one notice that Please check once

uday.
Автор

excellent teaching.thanks mr. pavan.
where can I get dataproviders class and excel utilities?

gauravchavan
Автор

I couldn't find the XLUtility file. So I paused the video and typed the whole thing, lol.

MGdriver
Автор

sir when i run UserTests it fails & give error FAILED: testUpdateUserByName
java.lang.AssertionError: expected [200] but found [301], seems like endpoints not working

piyushkotiyal
Автор

this API framework series is awesome
I want learn n create framework for testing web application using Selenium+java could you please share link for the same
so that I can answer folder structure n framework related interview questions.

rutujaadhav
Автор

Hi all! Did anybody face any issues on getUserByUserName test? on my side it is failing with 404: User not found, even though I have done everything as in the video

notsgpq
Автор

can you please share the data-provider and excel class file?

shekharadil
Автор

Pavan, if u don't mind, oculd u please share the data provider file and excel utility file in this chat.

Shridhar_Giri
Автор

public static String get_url = base_url+"/user/{username}"; - Not working not passing the name exactly

prasannavenkatesan
Автор

Mr. Pavan , great tutorial on building api infrastructure, where can we download this code from ? please provide a link, thanks

ronbarybaryosef
visit shbcf.ru