Data Driven API Testing Using Rest Assured

Data Driven API Testing Using Rest Assured

In this session, we would be looking into how we can perform the data-driven tests while doing API Testing using Rest assured.

As we all understand data-driven testing is an integral and important part while designing any testing framework as it helps us to segregate our test data from the code. 


So whenever any change happens in the data we don’t need to go and update that in code instead, we can update test data in our the source where we have kept it (Test Data can be kept either in excel or in some configuration or class files inside our project).

So In this session, we would be continuing doing some data driven test with One Sample API that we already have worked in our previous session.



As you have observed in my last blog we have done the hard coding of our Base URI and also every time when doing post requests we are taking the body from our code which is not good practice and should be avoided. Below is the code snapshot from my last blog.


In this session, we would be looking into two approaches of doing the Data-Driven Test while doing API Testing

รผ  Using Properties or Configuration file
รผ  Using Class File

Approach 1:

For Reading test data from Properties or configuration the file we can perform below steps




1)  Inside project main Folder under Configuration or any other Package of your choice create one text file with extension as .properties in this example I am creating one file named as Config.properties


2)  In these properties, the file declares the value in Key, value format of our Base URI.

3)  In project Base Class or in same test Class, declare one Properties variable and provide the path of .properties file along with below code snapshot.


4)  Now we are ready to use our Properties file inside test classes using below syntax.
pro.getProperty("BaseUrl");

Here, the getProperty method will take the Key of the property as a parameter and return the value of the matched key from the .properties file.


Approach 2:

Similarly for reading data from Another Class file we could follow the below steps:



1)  Inside project main Folder under Resources or any other Package of your choice create one class file let’s say TestResources.java


2)  In this Class create one static function and declare the body which we want to put in request and return that string.


3)  Finally Call this function inside our test class using
    classname.function name

The final Code for the API would look like below. If we observed carefully this code is much cleaner and easy to maintain than my last code.







SHARE THIS

Author:

My Name is Ankur Jain and I am currently working as Automation Test Architect.I am ISTQB Certified Test Manager,Certified UI Path RPA Developer as well as Certified Scrum Master with total 12 years of working experience with lot of big banking clients around the globe.I love to Design Automation Testing Frameworks with Selenium,Appium,Protractor,Cucumber,Rest-Assured, Katalon Studio and currently exploring lot in Dev-OPS as well. I am currently staying in Mumbai, Maharashtra. Please Connect with me through Contact Us page of this website.

Previous Post
Next Post
September 15, 2019 at 3:32 AM

Who approaches? Who claims it (don't make a presumption here))? By what means will it be conveyed back so you can move it to a contender's foundation?ExcelR Data Science Courses

Reply
avatar
February 18, 2020 at 2:10 PM

Such a very useful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.
360DigiTMG artificial intelligence course in hyderabad

Reply
avatar
June 11, 2020 at 1:58 PM

This post is very simple to read and appreciate without leaving any details out. Great work!
Data Science Certification in Bangalore

Reply
avatar
June 12, 2020 at 10:37 PM

I would like to say that this blog really convinced me to do it! Thanks, very good post.
Data Science Training in Bangalore

Reply
avatar
June 27, 2020 at 2:07 PM

Hello, I have browsed most of your posts. This post is probably where I got the most useful information for my research. Thanks for posting, maybe we can see more on this. Are you aware of any other websites on this subject. free instagram likes instantly without password

Reply
avatar
July 5, 2020 at 6:53 PM

You completed a number of nice points there. I did a search on the issue and found nearly all people will have the same opinion with your blog.
Data Science Training in Bangalore

Reply
avatar
August 12, 2020 at 8:07 AM

Very impressive and interesting blog found to be well written in a simple manner that everyone will understand and gain the enough knowledge from your blog being more informative is an added advantage for the users who are going through it. Once again nice blog keep it up.

360DigiTMG Data Analytics Course

Reply
avatar
September 4, 2020 at 7:18 PM

This is actually the data I'm searching for, I was unable to have requested a less difficult perused with extraordinary tips this way... Much appreciated!
data science course in delhi

Reply
avatar
September 10, 2020 at 3:57 PM

Excellent post. I learned a lot from this blog and I suggest my friends to visit your blog to learn new concept about technology.Best data science courses in hyerabad

Reply
avatar
October 21, 2020 at 1:19 PM

I found hubwit as a transparent site, a social hub which is a conglomerate of Buyers and Sellers who are ready to offer online digital consultancy at decent cost.
Best Institute for Data Science in Hyderabad

Reply
avatar
November 2, 2020 at 4:31 PM

Set aside my effort to peruse all the remarks, however I truly delighted in the article. It's consistently pleasant when you can not exclusively be educated, yet in addition, engaged!
https://360digitmg.com/masters-in-full-stack-data-scientist-course/

Reply
avatar
November 21, 2020 at 6:41 PM

Thanks for sharing great information. I highly recommend you.data science courses

Reply
avatar
March 1, 2021 at 10:57 AM

Amazing journal. I appreciated studying your articles. this can be extremely a fantastic perused on behalf of me. I even have bookmarked it and that i am anticipating studying new articles. Keep doing awesome!
data scientist certification

Reply
avatar
March 8, 2021 at 1:45 AM

I recently came across your article and read it. I want to express my admiration for your writing skills and your ability to get readers to read from start to finish. I would love to read more recent articles and share my thoughts with you.
Data Science Course in Pune

Reply
avatar
March 15, 2021 at 6:05 PM

Thanks for your nice post I really like it and appreciate it. My work is about Custom Vape Cartridge Boxes. If you need perfect quality boxes then you can visit our website.

Reply
avatar
March 18, 2021 at 3:23 PM

Very awesome!!! When I searched for this I found this website at the top of all blogs in search engines.

business analytics course


Reply
avatar
October 27, 2021 at 7:49 PM

This is just the information I am finding everywhere. Thanks for your blog, I just subscribe your blog. This is a nice blog..
data scientist course in malaysia

Reply
avatar
January 4, 2022 at 5:50 PM

This blog was really great, never seen a great blog like this before. i think im gonna share this to my friends..
data science training in hyderabad

Reply
avatar
March 28, 2022 at 7:21 PM

Extremely overall quite fascinating post. I was searching for this sort of data and delighted in perusing this one.
Continue posting. A debt of gratitude is in order for sharing.data science course in warangal


Reply
avatar
April 21, 2022 at 9:18 AM

Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained! data analytics courses malaysia

Reply
avatar
April 22, 2022 at 4:05 PM

Great Article it its really informative and innovative keep us posted with new updates. its was really valuable. thanks a lot.
business analytics training in hyderabad

Reply
avatar
July 8, 2022 at 10:25 AM

"If you are also one of them and want to know what the companies demand from the data scientists to do in their organization, you have come to the right place.data science course in kolkata"

Reply
avatar
August 11, 2022 at 1:30 PM

360DigiTMG offers the best Data Science courses in the market. Join and become a professional Data Scientist.business analytics course in ludhiana

Reply
avatar
August 23, 2022 at 10:31 AM

Statistics is also an essential component of data science as it makes numerical roots of data. You cannot imagine data science without statisticsdata science training in vadodara.

Reply
avatar
October 28, 2024 at 1:20 PM

This was exactly the advice I needed. Thank you for always providing clear, actionable steps that make understanding the topic much easier.
Data science courses in Noida

Reply
avatar
October 29, 2024 at 4:35 PM

Data-driven API testing using Rest Assured allows testers to execute the same test case with multiple sets of data, enhancing test coverage and efficiency. This approach simplifies the management of test data, making it easy to validate API responses across various input scenarios. By leveraging data-driven techniques, you can ensure your APIs are robust and perform as expected under different conditions.

Data Science Courses in Kolkata

Reply
avatar
November 8, 2024 at 3:14 PM

This is a great guide on implementing data-driven testing in API testing with Rest Assured! I particularly appreciate how you break down two approaches to separating test data from the code: using properties/configuration files and class files.
Data science courses in Visakhapatnam

Reply
avatar
November 8, 2024 at 5:10 PM

"Nice write-up! If you're looking to upskill in data science, be sure to check out the Data science courses in Brighton. It's a great learning opportunity for anyone wanting to get ahead in the field!"

Reply
avatar
November 19, 2024 at 9:31 PM

This blog offers a clear and practical explanation of data-driven API testing using Rest Assured. The step-by-step approaches for configuration and class-based methods make it beginner-friendly and efficient. Great job simplifying complex concepts!
Data science courses in Gujarat

Reply
avatar
November 20, 2024 at 10:27 PM

"Very informative! For those interested in exploring data science further, I highly recommend checking out the Data Science courses in Kochi. It's a great way to gain valuable expertise."

Reply
avatar
November 24, 2024 at 3:18 PM

Data-driven API testing using Rest Assured allows you to test APIs with different sets of input data, improving the coverage and reliability of your tests. By using external data sources like CSV, Excel, or JSON files, you can easily automate and scale your API testing efforts.

Data science courses in Pune

Reply
avatar
December 4, 2024 at 12:27 PM

"Fantastic post on API data-driven testing using Rest Assured! I appreciate how clearly you've explained the process of setting up and executing data-driven tests for APIs. The practical examples and step-by-step guide make it easy to understand and implement in real-world projects. Thanks for sharing this insightful resource for API testing!"
Data science courses in the Netherlands

Reply
avatar
December 4, 2024 at 1:43 PM

Fantastic explanation! This is exactly what I needed to understand data-driven testing with Rest Assured. Thanks for sharing your insights.
Data science Courses in Sydney

Reply
avatar
December 6, 2024 at 12:33 PM

The examples you provided were so relatable! This post is packed with value.
Data science Courses in London

Reply
avatar
December 7, 2024 at 4:20 PM

Thank you for the detailed explanation on API data-driven testing with REST Assured! I’ve always found API testing a bit daunting, but this article breaks it down step by step. The example you provided of integrating data-driven tests with a CSV file is really helpful. I’ll definitely be using this in my next testing project. Keep the great content coming!
Data science courses in Glasgow

Reply
avatar
December 8, 2024 at 6:27 PM

Your explanation of API data-driven testing using Rest Assured is outstanding! It’s such a helpful resource for testers.

Data science courses in France

Reply
avatar
December 13, 2024 at 1:21 AM

Data-driven testing with Rest Assured is a great approach to make API testing more efficient by separating test data from the test code itself. This method ensures that when data changes, you only need to update the data source, not the test scripts, leading to more maintainable and scalable tests. Using tools like Excel or configuration files to manage test data simplifies the process and enhances flexibility in testing scenarios.

Data science Courses in City of Westminster

Neel KBH
kbhneel@gmail.com

Reply
avatar
December 13, 2024 at 4:55 PM

This article on data-driven API testing with Rest Assured is highly informative and well-structured. It effectively demonstrates how to use external data sources, such as Excel or JSON, to create dynamic test cases, enhancing testing scalability. The inclusion of practical examples and clear explanations makes it accessible even to beginners. A must-read for anyone looking to implement robust and reusable API testing strategies with Rest Assured.
Thank you for the article.
Data science Courses in Berlin







Reply
avatar
December 18, 2024 at 8:46 PM

This post provides an insightful explanation of implementing data-driven testing in API automation using Rest Assured. By leveraging properties files and class files to manage test data, it effectively demonstrates how to enhance code maintainability and reduce hardcoding, resulting in a cleaner and more scalable testing framework.
Data science Courses in Ireland

Reply
avatar
December 30, 2024 at 9:15 PM

Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic.
Data Analytics Courses In Chennai

Reply
avatar
January 6, 2025 at 3:45 PM

Your article on API data-driven testing using Rest Assured is an excellent resource for testers. The detailed steps and examples make it easy to follow. Thanks for this comprehensive guide!
digital marketing course in chennai fees

Reply
avatar
January 24, 2025 at 12:35 AM

The hands-on projects in the Digital Marketing Course in Dwarka really helped me understand digital marketing better. Excellent course!

Reply
avatar