Skip to content

Commit e15b245

Browse files
Merge branch 'main' of github.com:NHSDigital/bcss-playwright into feature/BCSS-20626-fit-kit-markdown-updates
2 parents 5e322f9 + cc54a4c commit e15b245

File tree

1 file changed

+38
-11
lines changed

1 file changed

+38
-11
lines changed

docs/utility-guides/LoadProperties.md

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ The Load Properties Utility can be used to retrieve values from a properties fil
77
- [Utility Guide: Load Properties](#utility-guide-load-properties)
88
- [Table of Contents](#table-of-contents)
99
- [How This Works](#how-this-works)
10+
- [Adding to the Properties File](#adding-to-the-properties-file)
1011
- [Using the Load Properties Utility](#using-the-load-properties-utility)
11-
- [Example usage](#example-usage)
12+
- [Example Usage](#example-usage)
1213

1314
## How This Works
1415

@@ -24,13 +25,37 @@ To ensure that there are no mistakes when providing this input there are two add
2425
1. `get_smokescreen_properties()`: Which will load `self.smokescreen_properties_file`
2526
2. `get_general_properties()`: Which will load `self.general_properties_file`
2627

28+
## Adding to the Properties File
29+
2730
To add values to the properties file follow the format:
2831

29-
# ----------------------------------
30-
# EXAMPLE VALUES
31-
# ----------------------------------
32-
example_value_1=value1
33-
example_value_2=value2
32+
```java
33+
# ----------------------------------
34+
# Example Values
35+
# ----------------------------------
36+
example_value_1=value1
37+
example_value_2=value2
38+
```
39+
40+
**Reasoning for storing values in the properties file:**
41+
42+
1. Properties files use key-value pairs because they provide a simple, organized, and flexible way to store configuration data.
43+
44+
2. Each line in the file assigns a value to a key (For example, c1_daily_invitation_rate=10). This makes it easy to look up and change values as needed.
45+
46+
3. Using key-value pairs in properties files helps keep your tests clean, flexible, and easy to maintain by avoiding hard-coded values in your test scripts.
47+
48+
**Why avoid hard coded values in tests?**
49+
50+
1. Maintainability: If we need to update a value (like a test organization ID or a rate), we only have to change it in one place—the properties file—instead of searching through all your test code.
51+
52+
2. Reusability: The same test code can be run with different data just by changing the properties file, making your tests more flexible.
53+
54+
3. Separation of Concerns: Test logic stays in your code, while test data and configuration are kept separate in the properties file.
55+
56+
4. Readability: It’s easier to see and manage all your test settings and data in one file.
57+
58+
5. Environment Flexibility: We can have different properties files for different environments (e.g., Development, Test, Production) without changing your test code.
3459

3560
## Using the Load Properties Utility
3661

@@ -41,9 +66,11 @@ Here there are two fixtures:
4166
1. `smokescreen_properties` - which is used to load the file: tests/smokescreen/bcss_smokescreen_tests.properties
4267
2. `get_general_properties` - which is used to load the file: tests/bcss_tests.properties
4368

44-
## Example usage
69+
## Example Usage
4570

46-
def test_example_1(page: Page, general_properties: dict) -> None:
47-
print(
48-
general_properties["example_value_1"]
49-
)
71+
```python
72+
def test_example_1(page: Page, general_properties: dict) -> None:
73+
print(
74+
general_properties["example_value_1"]
75+
)
76+
```

0 commit comments

Comments
 (0)