|
1 | | -# imms_fhir_api_automation |
| 1 | +# End-to-end Automation Tests |
2 | 2 |
|
3 | | -pytest-bdd Automation for Immunisation FHIR API |
| 3 | +This directory contains End-to-end Automation Tests for the Immunisation FHIR API. |
4 | 4 |
|
5 | | -## Need to check in case any other libraries to be added |
| 5 | +## Setting up e2e_automation tests to run locally |
6 | 6 |
|
7 | | -## Installation |
| 7 | +1. Follow the instructions in the root level README.md to setup the [dependencies](../../README.md#environment-setup) and create a [virtual environment](../../README.md#setting-up-a-virtual-environment-with-poetry) for this folder (`e2e_automation`). |
8 | 8 |
|
9 | | -This test pack requires Python 3.10 installed on the system or greater to run. |
| 9 | +2. Add values to the .env file. |
10 | 10 |
|
11 | | -To execute the tests from your system, please follow the 4 easy steps below: |
| 11 | + For an example of a template .env file, see [.env.example](./.env.example). |
12 | 12 |
|
13 | | -1. Clone the repo to any local folder |
14 | | -2. Create a virtual environment |
| 13 | + The following values should be added: |
15 | 14 |
|
16 | | - ```console |
17 | | - # python -m venv .venv |
18 | 15 | ``` |
19 | | - |
20 | | -3. Install all dependencies |
21 | | - |
22 | | - ```console |
23 | | - # pip install -r .\requirements.txt |
| 16 | + aws_token_refresh=True |
| 17 | + baseUrl=https://internal-qa.api.service.nhs.uk/immunisation-fhir-api/FHIR/R4 |
| 18 | + auth_url=https://internal-qa.api.service.nhs.uk/oauth2-mock/authorize |
| 19 | + token_url=https://internal-qa.api.service.nhs.uk/oauth2-mock/token |
| 20 | + callback_url=https://oauth.pstmn.io/v1/callback |
| 21 | + S3_env=internal-qa |
| 22 | + aws_profile_name={your-profile} |
24 | 23 | ``` |
25 | 24 |
|
26 | | -4. To activate env |
27 | | - a. in git bash terminal |
28 | | - `console |
29 | | -source .venv/Scripts/activate |
30 | | -` |
31 | | - b. in Terminal |
32 | | - `console |
33 | | - .venv\Scripts\Activate.ps1 |
34 | | -` |
| 25 | +3. Add login and secret values to the .env file. |
35 | 26 |
|
36 | | -5. Need to create .env file, please get in touch with Imms FHIR API Test team to get the content of the file |
| 27 | + **Please contact the Imms FHIR API Test team to get these values.** |
37 | 28 |
|
38 | | -6. run following command to see that test are discovered |
| 29 | + The following values should be added: |
39 | 30 |
|
40 | | - ```console |
41 | | - # pytest --collect-only |
| 31 | + ``` |
| 32 | + username |
| 33 | + scope |
| 34 | + Postman_Auth_client_Id |
| 35 | + Postman_Auth_client_Secret |
| 36 | + RAVS_client_Id |
| 37 | + RAVS_client_Secret |
| 38 | + MAVIS_client_Id |
| 39 | + MAVIS_client_Secret |
| 40 | + EMIS_client_Id |
| 41 | + EMIS_client_Secret |
| 42 | + SONAR_client_Id |
| 43 | + SONAR_client_Secret |
| 44 | + TPP_client_Id |
| 45 | + TPP_client_Secret |
| 46 | + MEDICUS_client_Id |
| 47 | + MEDICUS_client_Secret |
42 | 48 | ``` |
43 | 49 |
|
44 | | -7. install and configure Aws CLI using following commands: |
45 | | - 1. pip install awscli |
46 | | - 2. aws configure |
47 | | - 3. if you want to use aws configure sso then install aws cli 2 and follow the instructions on AWS access key page. |
48 | | - |
49 | | -8. to update the python packages run command 1 and to update requirement file run command 2. |
50 | | - 1. python -m pip install --upgrade <package name> |
51 | | - 2. python -m pip freeze > requirements.txt |
52 | | - |
53 | | -----DO NOT USE BELOW--------------------------------------------- |
54 | | - |
55 | | -## Reporting |
56 | | - |
57 | | -To create the json report - |
58 | | -pip install allure-behave |
59 | | - |
60 | | -Command - |
61 | | -behave -f allure_behave.formatter:AllureFormatter -o output/allure-results |
62 | | - |
63 | | -## To convert the json file to html in Allure Reporting |
64 | | - |
65 | | -Dwnload the latest release allure-2.32.2.zip Allure Package from <https://github.com/allure-framework/allure2/releases> |
66 | | -Unzip the folder and add the bin directory to system variable path |
67 | | - |
68 | | -Command to convert the json reports to html - |
69 | | -allure serve output/allure-results |
70 | | - |
71 | | -Command to generate the html report manually if BROWSE does not work - |
72 | | -allure generate output/allure-results -o output/allure-report --clean |
73 | | - |
74 | | -Start a http server to view the results - |
75 | | -python -m http.server |
76 | | - |
77 | | -## To Open the index.html file |
78 | | - |
79 | | -once the allure plug in place then we need to update the ymal with following code : |
80 | | -''' |
81 | | - |
82 | | -- script: | |
83 | | - source venv/bin/activate |
84 | | - pytest --junitxml=output/test-results.xml --alluredir=output/allure-results || true |
85 | | - displayName: 'Run Pytest-BDD tests with Allure' |
86 | | - |
87 | | -- task: Bash@3 |
88 | | - displayName: 'Generate Allure Report' |
89 | | - inputs: |
90 | | - targetType: 'inline' |
91 | | - script: | |
92 | | - allure generate output/allure-results --clean -o output/allure-report |
93 | | - |
94 | | -- script: ls -la output/allure-report |
95 | | - displayName: 'List Allure Report Contents' |
| 50 | +4. Run `poetry install --no-root` to install dependencies. |
96 | 51 |
|
97 | | -- task: PublishBuildArtifacts@1 |
98 | | - displayName: 'Publish Allure Report Artifact' |
99 | | - inputs: |
100 | | - pathToPublish: 'output/allure-report' |
101 | | - artifactName: 'AllureReport' |
102 | | - publishLocation: 'Pipeline' |
| 52 | +5. The `Makefile` in this directory provides the following commands: |
103 | 53 |
|
104 | | -''' |
| 54 | +- `make test` - run all tests (may take some time) |
| 55 | +- `make smoke-test` - run smoke tests only (quicker) |
| 56 | +- `make collect-only` - check that all tests are discovered |
0 commit comments