|
| 1 | +# Utility Guide: Load Properties |
| 2 | + |
| 3 | +The Load Properties Utility can be used to retrieve values from a properties file. |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | + |
| 7 | +- [Utility Guide: Load Properties](#utility-guide-load-properties) |
| 8 | + - [Table of Contents](#table-of-contents) |
| 9 | + - [How This Works](#how-this-works) |
| 10 | + - [Using the Load Properties Utility](#using-the-load-properties-utility) |
| 11 | + - [Example usage](#example-usage) |
| 12 | + |
| 13 | +## How This Works |
| 14 | + |
| 15 | +This utility uses the `jproperties` package to load the properties files.<br> |
| 16 | +There is a class `PropertiesFile`, containing the locations of both files: |
| 17 | + |
| 18 | +1. `self.smokescreen_properties_file`: tests/smokescreen/bcss_smokescreen_tests.properties |
| 19 | +2. `self.general_properties_file`: tests/bcss_tests.properties |
| 20 | + |
| 21 | +The method `get_properties()` will load either one of these based on the input provided.<br> |
| 22 | +To ensure that there are no mistakes when providing this input there are two additional methods to call that will do this for you: |
| 23 | + |
| 24 | +1. `get_smokescreen_properties()`: Which will load `self.smokescreen_properties_file` |
| 25 | +2. `get_general_properties()`: Which will load `self.general_properties_file` |
| 26 | + |
| 27 | +To add values to the properties file follow the format: |
| 28 | + |
| 29 | + # ---------------------------------- |
| 30 | + # EXAMPLE VALUES |
| 31 | + # ---------------------------------- |
| 32 | + example_value_1=value1 |
| 33 | + example_value_2=value2 |
| 34 | + |
| 35 | +## Using the Load Properties Utility |
| 36 | + |
| 37 | +To use this utility in a test reference the pytest fixture in `conftest.py`.<br> |
| 38 | +There is no need to import anything as any fixtures in `conftest.py` will be automatically discovered by pytest. |
| 39 | +Here there are two fixtures: |
| 40 | + |
| 41 | +1. `smokescreen_properties` - which is used to load the file: tests/smokescreen/bcss_smokescreen_tests.properties |
| 42 | +2. `get_general_properties` - which is used to load the file: tests/bcss_tests.properties |
| 43 | + |
| 44 | +## Example usage |
| 45 | + |
| 46 | + def test_example_1(page: Page, general_properties: dict) -> None: |
| 47 | + print( |
| 48 | + general_properties["example_value_1"] |
| 49 | + ) |
0 commit comments