|
1 | 1 | # Getting Started #2: Blueprint File Breakdown |
| 2 | + |
| 3 | +This guide outlines the breakdown of this blueprint, and specifically the files of importance for running Playwright Pytest. |
| 4 | + |
| 5 | +## Contents |
| 6 | + |
| 7 | +- [Getting Started #2: Blueprint File Breakdown](#getting-started-2-blueprint-file-breakdown) |
| 8 | + - [Contents](#contents) |
| 9 | + - [Directories \& Files Directly Impacting Tests](#directories--files-directly-impacting-tests) |
| 10 | + - [`requirements.txt`](#requirementstxt) |
| 11 | + - [`pytest.ini`](#pytestini) |
| 12 | + - [`tests/`](#tests) |
| 13 | + - [`pages/`](#pages) |
| 14 | + - [`utils/`](#utils) |
| 15 | + - [Directories \& Files Specific For This Repo](#directories--files-specific-for-this-repo) |
| 16 | + |
| 17 | +## Directories & Files Directly Impacting Tests |
| 18 | + |
| 19 | +The files in this section cover the files that impact your ability to execute tests. |
| 20 | + |
| 21 | +### `requirements.txt` |
| 22 | + |
| 23 | +This file outlines the packages required from the Python Package Index (PyPI) to execute this project. This should be regularly maintained to ensure that we have the most up-to-date versions of any packages we intend to use. |
| 24 | + |
| 25 | +### `pytest.ini` |
| 26 | + |
| 27 | +This file outlines the configuration of pytest, and ultimately how Playwright also executes. A couple of things to note: |
| 28 | + |
| 29 | +- The `log_cli` section covers default logging provided by pytest - we have defaulted this to on at INFO level, but this can be amended as needed. |
| 30 | +- The `addopts` section will run any commands you want to run by default for each execution and can be overwritten using the appropriate options via the command line. For example, you can override the `--tracing` level to on by executing pytest using: `pytest --tracing=on`. |
| 31 | +- The `markers` section is for organizing any marks (or tags) you want to apply to your tests, for example by a business area or a testing type. If you don't include your marks in this list, pytest will give you a warning until they have either been added here or programmatically within the code. |
| 32 | + |
| 33 | +Any configuration you want to apply to all of your test executions should be placed in this file where possible, to ensure easy maintenance. |
| 34 | + |
| 35 | +### `tests/` |
| 36 | + |
| 37 | +This directory is designed to house all of your tests intended for execution. |
| 38 | + |
| 39 | +Because we want to treat this directory as a [Python package](https://docs.python.org/3/tutorial/modules.html#packages), there is a blank `__init__.py` file present in this directory that should remain present. |
| 40 | + |
| 41 | +### `pages/` |
| 42 | + |
| 43 | +This directory is designed to house all of your [page object model](https://playwright.dev/python/docs/pom) classes, to facilitate reusable code and easy to maintain tests. |
| 44 | + |
| 45 | +We want this directory to be treated as a [Python package](https://docs.python.org/3/tutorial/modules.html#packages), so there is a blank `__init__.py` file present in this directory that should remain present. |
| 46 | + |
| 47 | +### `utils/` |
| 48 | + |
| 49 | +This directory is designed to house any utility classes that would assist in test execution. We provide some utility classes as part of this blueprint, but as you begin testing your own applications you may find that these utilities may need to be expanded or you need something different from what has been provided. For example, you may create a utility class for logging into your application - that code should go in this directory. |
| 50 | + |
| 51 | +We want this directory to be treated as a [Python package](https://docs.python.org/3/tutorial/modules.html#packages), so there is a blank `__init__.py` file present in this directory that should remain present. |
| 52 | + |
| 53 | +> NOTE: If you write a utility class for your own project that you think other projects may benefit from and can be applied in a generic way, please raise a [Feature Request](https://github.com/nhs-england-tools/playwright-python-blueprint/issues/new/choose) as we welcome any contributions of this fashion. |
| 54 | +
|
| 55 | +## Directories & Files Specific For This Repo |
| 56 | + |
| 57 | +The following directories and files are specific for this repository (playwright-python-blueprint), and may require modification or removal |
| 58 | +if transferring this code into a new repository. |
| 59 | + |
| 60 | +- `.github/`: This directory has the code used to manage our repo and pipelines including CI/CD checks. You may find some useful for your own repo, especially if you are using GitHub to manage your code. |
| 61 | +- `.vscode/`: This directory houses the default recommended configuration and settings for VSCode, if you use it as an IDE. |
| 62 | +- `docs/`: This directory houses the documentation for this repo (including documents like this one). |
| 63 | +- `scripts/`: This directory houses the scripts used by this repo, primarily as part of the CI/CD checks. |
| 64 | +- `tests_utils/`: This directory houses the unit tests for the utilities provided by this repo. You may want to copy these over if you want to ensure utilities are behaving as expected. |
| 65 | +- `.editorconfig`, `.gitattributes`, `.gitignore`, `.gitleaks.toml`, `.gitleaksignore`: These files are configuration for git, and quality and security checks provided via the CI/CD checks. |
0 commit comments