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 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
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:
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.
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.
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
ReplySuch 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.
Reply360DigiTMG artificial intelligence course in hyderabad
This post is very simple to read and appreciate without leaving any details out. Great work!
ReplyData Science Certification in Bangalore
I would like to say that this blog really convinced me to do it! Thanks, very good post.
ReplyData Science Training in Bangalore
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
ReplyAwesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work!
ReplyData Science Institute in Bangalore
I am really enjoying reading your well written articles. It looks like you spend a lot of effort and time on your blog. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work.
ReplyData Science Certification in Bangalore
If it's not too much trouble share more like that.
ReplyData Science Course in Bangalore
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.
ReplyData Science Training in Bangalore
I feel really happy to have seen your post and look forward to so many more interesting post reading here. Thanks once more for all the details.Learn Best Data Science Training in Hyderabad
ReplyVery interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This article inspired me to read more. keep it up.
ReplyCorrelation vs Covariance
Simple linear regression
data science interview questions
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.
Reply360DigiTMG Data Analytics Course
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!
Replydata science course in delhi
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
ReplyI 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.
ReplyBest Institute for Data Science in Hyderabad
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!
Replyhttps://360digitmg.com/masters-in-full-stack-data-scientist-course/
Very great post. I just discovered your blog and needed to state that I have truly appreciated perusing your blog entries. Any way I'll be buying in to your feed and I trust you post again soon.
Replydata scientist course
Thanks for sharing great information. I highly recommend you.data science courses
ReplyHello! I just want to give a big thank you for the great information you have here in this post. I will probably come back to your blog soon for more information!
ReplyData Analytics Course in Bangalore
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!
Replydata scientist certification
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.
ReplyData Science Course in Pune
Honestly speaking this blog is absolutely amazing in learning the subject that is building up the knowledge of every individual and enlarging to develop the skills which can be applied in to practical one. Finally, thanking the blogger to launch more further too.
ReplyData Analytics online course
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.
ReplyVery awesome!!! When I searched for this I found this website at the top of all blogs in search engines.
Replybusiness analytics course
Great to become visiting your weblog once more, it has been a very long time for me. Pleasantly this article i've been sat tight for such a long time. I will require this post to add up to my task in the school, and it has identical subject along with your review. Much appreciated, great offer. data science course in nagpur
Replyi am glad to discover this page : i have to thank you for the time i spent on this especially great reading !! i really liked each part and also bookmarked you for new information on your site.
Replyartificial intelligence training in chennai
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 scientist course in delhi
ReplyThis is just the information I am finding everywhere. Thanks for your blog, I just subscribe your blog. This is a nice blog..
Replydata scientist course in malaysia
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 lucknow
ReplyStupendous blog huge applause to the blogger and hoping you to come up with such an extraordinary content in future. Surely, this post will inspire many aspirants who are very keen in gaining the knowledge. Expecting many more contents with lot more curiosity further.
ReplyData Science Certification in Bhilai
This blog was really great, never seen a great blog like this before. i think im gonna share this to my friends..
Replydata science training in hyderabad
I want to leave a little comment to support and wish you the best of luck.we wish you the best of luck in all your blogging enedevors
Replybusiness analytics course in varanasi
Superbly written article, if only all bloggers offered the same content as you, the internet would be a far better place.. data analytics course in mysore
ReplyImpressive blog to be honest definitely this post will inspire many more upcoming aspirants. Eventually, this makes the participants to experience and innovate themselves through knowledge wise by visiting this kind of a blog. Once again excellent job keep inspiring with your cool stuff.
ReplyData Science Training in Bhilai
Truly overall quite fascinating post. I was searching for this sort of data and delighted in perusing this one. Continue posting. Much obliged for sharing.data science course in bhopal
ReplyExtremely overall quite fascinating post. I was searching for this sort of data and delighted in perusing this one.
ReplyContinue posting. A debt of gratitude is in order for sharing.data science course in warangal
I want to leave a little comment to support and wish you the best of luck.we wish you the best of luck in all your blogging enedevors
Replydata science course in faridabad
I want to leave a little comment to support and wish you the best of luck.we wish you the best of luck in all your blogging enedevors
Replydata scientist course in trivandrum
Unquestionably generally speaking very intriguing post. I was looking for such an information and totally savored the experience of examining this one. Keep on posting. A responsibility of appreciation is all together for sharing.business analytics course in bhubaneswar
ReplyTook 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
ReplyGreat Article it its really informative and innovative keep us posted with new updates. its was really valuable. thanks a lot.
Replybusiness analytics training in hyderabad
It's been seen that there is no doubt that the demand for data science course will increase in the future. data science course in chandigarh
Reply"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"
Reply360DigiTMG offers the best Data Science courses in the market. Join and become a professional Data Scientist.business analytics course in ludhiana
ReplyStatistics 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