Skip to content

Commit cc54a4c

Browse files
BCSS – Playwright - Load Properties Markdown Improvements (#89)
BCSS – Playwright - Load Properties Markdown Improvements, Implemented the Code Refactoring. <!-- markdownlint-disable-next-line first-line-heading --> ## Description <!-- Describe your changes in detail. --> "Example Usage" with Python code block is added to the top level summary explaining the reasoning for the properties files which use key value pairs and also the reason for using it is to avoid hard coded values in our tests. <!-- Why is this change required? What problem does it solve? --> ## Type of changes Example Usage with Python code block is added to the Top Level Summary. Total File Updated - 1 (Name - LoadProperties.md) <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply. --> - [X] Refactoring (non-breaking change) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would change existing functionality) - [ ] Bug fix (non-breaking change which fixes an issue) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [X] I am familiar with the [contributing guidelines](https://github.com/nhs-england-tools/playwright-python-blueprint/blob/main/CONTRIBUTING.md) - [X] I have followed the code style of the project - [ ] I have added tests to cover my changes (where appropriate) - [X] I have updated the documentation accordingly - [ ] This PR is a result of pair or mob programming --- ## Sensitive Information Declaration To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including [PII (Personal Identifiable Information) / PID (Personal Identifiable Data)](https://digital.nhs.uk/data-and-information/keeping-data-safe-and-benefitting-the-public) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter. - [X] I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.
1 parent 9fd9aba commit cc54a4c

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)