|
10 | 10 | 3. [AWS SSO Setup](#aws-sso-setup) |
11 | 11 | 4. [Other helpful commands](#other-helpful-commands) |
12 | 12 | 2. [Tests](#tests) |
13 | | -3. [Workflow](#workflow) |
14 | | -4. [Swagger](#swagger) |
15 | | -5. [ETL](#etl) |
| 13 | +3. [pytest tests](#pytest-tests) |
| 14 | +4. [End-to-End feature tests](#end-to-end-feature-tests) |
| 15 | +5. [Generate the Feature Test Postman collection](#generate-the-feature-test-postman-collection) |
| 16 | +6. [Workflow](#workflow) |
| 17 | +7. [Swagger](#swagger) |
| 18 | +8. [ETL](#etl) |
16 | 19 |
|
17 | 20 | --- |
18 | 21 |
|
|
22 | 25 |
|
23 | 26 | We use `asdf` to fetch the required versions of prerequisite libraries instead of your system's default version. To get it up and running go to https://asdf-vm.com/guide/getting-started.html. You can check it installed properly by using the command `asdf --version`. |
24 | 27 |
|
25 | | -If you are using `pyenv` (you can check by typing `pyenv` and seeing whether it returns a nice list of commands) then you should run: |
26 | | - |
27 | | -``` |
28 | | -pyenv install $(cat .python-version) |
29 | | -``` |
| 28 | +However, you will also need to install the `docker engine` separately |
30 | 29 |
|
31 | 30 | Additionally you will need `wget` (doing `which wget` will return blank if not installed). Please Google "how to install wget on my operating system", if you don't already have this installed. |
32 | 31 |
|
| 32 | +Update any dependencies on your system as required. |
| 33 | + |
33 | 34 | Otherwise `asdf` should do the work for you. |
34 | 35 |
|
| 36 | +### Useful tools |
| 37 | + |
| 38 | +`VScode` is useful and we have a workspace file setup to allow easy integration |
| 39 | + |
| 40 | +`Postman` &/or `Newman` Feature tests create a postman.collection which can be used for manual testing. |
| 41 | + |
35 | 42 | ### Project build |
36 | 43 |
|
37 | 44 | Do `make build` every time you would like to pick up and install new local/project dependencies and artifacts. This will always detect changes to: |
@@ -220,6 +227,52 @@ The VSCode settings for "Run and Debug" are also set up to run these tests if yo |
220 | 227 | `make test--sds--matrix` is used for testing responses match in SDS FHIR between CPM and LDAP. You must provide `SDS_PROD_APIKEY` and `SDS_DEV_APIKEY`. There are 3 optional variables `USE_CPM_PROD`, defaults to `FALSE`, `COMPARISON_ENV`, defaults to `local` and `TEST_COUNT`, defaults to `10` and is the number of requests to make. |
221 | 228 | Add `PYTEST_FLAGS='-sv'`. |
222 | 229 |
|
| 230 | +### End-to-End feature tests |
| 231 | + |
| 232 | +The Feature tests use `behave` (rather than `pytest`) to execute cucumber/gherkin-style end-to-end tests of specific features, in principle |
| 233 | +giving full end-to-end test coverage for API operations. |
| 234 | + |
| 235 | +Executing feature tests locally will give you a good idea whether you have implemented a well-behaved feature whilst in development (i.e. no need to redeploy whilst developing). |
| 236 | + |
| 237 | +Executing feature tests in integration mode will then give you confidence that the feature is ready to deploy in production, but has a much slower development cycle as it will need a full redeploy after codebase or infrastructure changes are implemented. |
| 238 | + |
| 239 | +#### Local |
| 240 | + |
| 241 | +To execute the feature tests entirely locally (executing lambdas directly, and otherwise mocking databases and responses to a high standard) you can do: |
| 242 | + |
| 243 | +```shell |
| 244 | +make test--feature-local |
| 245 | +``` |
| 246 | + |
| 247 | +If you would like to pass `behave` flags, e.g. to \[stop after the first failure\]: |
| 248 | + |
| 249 | +```shell |
| 250 | +make test--feature-local BEHAVE_FLAGS="--stop" |
| 251 | +``` |
| 252 | + |
| 253 | +#### Integration |
| 254 | + |
| 255 | +To execute the feature tests across the entire stack (including Apigee and AWS) you can do |
| 256 | + |
| 257 | +```shell |
| 258 | +make test--feature-integration |
| 259 | +``` |
| 260 | + |
| 261 | +### Generate the Feature Test Postman collection |
| 262 | + |
| 263 | +Our [end-to-end feature tests](#end-to-end-feature-tests) also generate working Postman collections. To generate the Postman collection quickly, without Apigee credentials, you can run the local feature tests. If you would like the Apigee |
| 264 | +credentials generating then you should run the integration feature tests. The generated files are: |
| 265 | + |
| 266 | +- `src/api/tests/feature_tests/postman-collection.json` |
| 267 | +- `src/api/tests/feature_tests/postman-environment.json` |
| 268 | + |
| 269 | +You can drag and drop `postman-collection.json` into the `Collections` tab on Postman, |
| 270 | +and `postman-environment.json` on to the `Environments` tab (remember to activate it). If you generated these |
| 271 | +with the local feature tests, then you will need to manually update the Apigee `baseUrl` and `apiKey` fields |
| 272 | +in the environment (but these are filled out already if generated with the integration feature tests). |
| 273 | + |
| 274 | +💡 **The feature tests are only guaranteed to work out-of-the-box with an empty database** |
| 275 | + |
223 | 276 | ## Workflow |
224 | 277 |
|
225 | 278 | In order to create new branches, use the commands listed below. Note that the commands will throw an error if |
|
0 commit comments