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
April 25, 2019 at 11:22 PM

I will use such information now. Great and capable recommendation by the creator of this blog are truly useful to lessen our hack-tic life Rent to Own Homes Toronto

Reply
avatar