Steps to Read Configuration from Properties File in Rest Assured Framework


Steps to Read Configuration from Properties File in Rest Assured Framework

What is configuration or properties file?
As we all are aware that it is not good practice to store hard coded values in the code, also it is against the basic coding principal so with the help of properties/configuration file, we can eliminate all these hard coded from our code.

For this purpose .properties files are used in Java programs to maintain configuration data, any project-specific setting such as browser name or any test data. All the values in this file are normally stored in the Key-Value Format.


So we need to follow below steps to a setup .properties file in our rest assured or any other testing framework.
1)Now Inside project main Folder under Configuration or any other Package of your choice add one text file with extension as .properties.

2)Inside these properties, file declare the value in Key, value format.
3)In project Base Class, declare one Property variable and provide the path of .properties file along with below code snapshot.



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



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

Now when we are going to execute code the compiler will read the data from this .properties file and this way we can also remove all the hard-coded values from our project.



Keep Learning, Keep Sharing J



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
Anonymous
April 19, 2022 at 10:44 AM

Steps To Read Configuration From Properties File In Rest Assured Framework - Qa Automation >>>>> Download Now

>>>>> Download Full

Steps To Read Configuration From Properties File In Rest Assured Framework - Qa Automation >>>>> Download LINK

>>>>> Download Now

Steps To Read Configuration From Properties File In Rest Assured Framework - Qa Automation >>>>> Download Full

>>>>> Download LINK 3t

Reply
avatar
July 8, 2022 at 1:15 AM

This method works perfectly fine for when calling from within the application. But when this property file needs to be tested against external calls, say, testing an API using Postman, it fails to load the properties.
Any fix for that?

Reply
avatar