Introduction of .properties file
A .properties file, distinguished by its .properties extension, is a text-based file structure. In this file format, each entry is stored as a key-value pair, with the key and value separated by an equal sign and each pair written on a separate line.
These files primarily serve to store configurations or data, including strings utilized for Internationalization and localization purposes. To handle .properties files in Java, the Properties class from the java.util package is utilized. This class, a legacy from JDK 1.0, inherits behavior from the Hashtable class, which is thread-safe and used within the Map interface of the Collection Framework.
key = value
testerName = Pradip
browser = Firefox
url = www.jbktutorials.com/
username = email@example.com
password = 12345
.properties files are extensively employed in Data-driven testing, a software testing approach involving the execution of identical steps with various sets of data. This method facilitates sourcing test data or output values from external data files, promoting flexibility and avoiding hardcoding. Consequently, it aids in maintaining a clear distinction between test scripts and data, enabling the execution of the same test scripts with multiple sets of input data and their corresponding expected results.
.properties files play a pivotal role in testing by segregating configurable parameters and settings from the codebase. This isolation empowers testers to modify values within the file without necessitating changes in the source code. Such files typically contain key-value pairs, encompassing details such as URLs, database configurations, environmental settings, and other constants essential in testing procedures. This separation streamlines test management, making it adaptable across various testing environments.
These files offer versatility, facilitating manageability and reusability in the testing process, allowing testers to configure and manage different aspects of their tests without directly altering the codebase.