Skip to content

Commit 58c7e9a

Browse files
[NDH-794] Add Testing Strategy Documentation (#398)
* add testing strategy documentation * updating TOC * update changelog
1 parent fbc7cfb commit 58c7e9a

File tree

1 file changed

+38
-9
lines changed

1 file changed

+38
-9
lines changed

CONTRIBUTING.md

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
| Updated | 2029-10-15 | @abachman-dsac | addressing feedback from #108 |
77
| Updated | 2029-12-03 | @abachman-dsac | adding notes on `make` and `bin/npr` |
88
| Updated | 2026-01-28 | @sachin-panayil| updating links with new path |
9+
| Updated | 2026-02-10 | @spopelka-dsac | updating testing documentation |
910

1011
- [How to Contribute](#how-to-contribute)
1112
- [Getting Started](#getting-started)
@@ -24,6 +25,8 @@
2425
- [Workflow and Branching](#workflow-and-branching)
2526
- [Testing Conventions](#testing-conventions)
2627
- [Backend Tests](#backend-tests)
28+
- [Frontend Tests](#frontend-tests)
29+
- [End to End Tests](#end-to-end-tests)
2730
- [Coding Style and Linters](#coding-style-and-linters)
2831
- [Writing Issues](#writing-issues)
2932
- [Creating Commits](#creating-commits)
@@ -217,26 +220,52 @@ We follow the [GitHub Flow Workflow](https://guides.github.com/introduction/flow
217220

218221
### Testing Conventions
219222

220-
It is an expectation of this project that each feature will have new automated
221-
tests prior to opening a pull request and that all the tests in the repo are
222-
passing.
223+
With each pull request against main, automated GitHub actions will run the full NPD test suite (including Django unit tests, React unit tests, and end-to-end tests) against the codebase. Branch protections prevent pull requests from being merged unless all tests are passing.
223224

224-
We do not expect 100% test coverage but we will be unlikely to accept Pull
225-
Requests which reduce test coverage or new features which do not include
226-
updates to the test suite.
225+
It is an expectation of this project that every pull request for a new feature will include unit tests and end-to-end tests that appropriately flex the edge cases of the feature being implemented or the change being made.
226+
227+
It is also an expectation of this project that any bug fixes will begin with the addition of new unit and/or end-to-end tests that demonstrates the bug conditions. The test(s) should pass after the bug fix is complete.
228+
229+
We do not expect 100% test coverage, but we will be unlikely to accept pull requests that reduce test coverage or pull requests for new features/ bug fixes that do not also introduce appropriate tests.
227230

228231
We recommend starting new feature work with a new Playwright end-to-end test and going from there.
229232

230233
#### Backend Tests
231234

232-
The backend test suite can be found in the `tests.py` file currently in
233-
`backend/npdfhir/tests.py`. The test suite can be run by navigating to the
234-
`backend` folder and running `make test` or `python manage.py test`.
235+
Any modifications that change the underlying data model, behavior of the API, or authentication should include Django unit tests that create appropriate test records and assertions to flex the main conditions and edge cases associated with the change.
236+
237+
Currently, the backend tests fall into three main categories:
238+
* [Overall application tests, including routing](/backend/app/tests/)
239+
* [Static content delivery tests, including feature flag settings](/backend/provider_directory/tests/)
240+
* [Data model and API tests, separated by FHIR endpoint](/backend/npdfhir/tests/)
241+
242+
The full backend test suite can be run by executing the command `make test-backend` or by navigating to the
243+
`backend` folder and running `python manage.py test`.
244+
245+
Best Practices:
246+
* Test methods should be clearly named to describe the scenarios that they are testing
247+
* Test data should be generated to support flexing edge cases (with comments to describe the test cases)
248+
* Filter tests should verify both the intended inclusion and exclusion established by the filter
235249

236250
Please refer to the [Django
237251
documentation](https://docs.djangoproject.com/en/5.2/topics/testing/overview/)
238252
on testing for additional details.
239253

254+
#### Frontend Tests
255+
Any modifications that change the React components or introduce new pages should include react unit tests that validate that the new components and pages are rendering correctly undes the expected logical conditions.
256+
257+
The frontend tests can be found throughout the [frontend folder](/frontend/src), denoted by `.test` in the filename.
258+
259+
The full frontend test suite can be run by executing the command `make test-frontend`, which also spins up a test server for mocked requests.
260+
261+
#### End-to-End Tests
262+
NPD utilizes Playwright for automated end-to-end testing. Any modifications that change either frontend or backend behavior should have an associated end-to-end test for that specific change, as well as a new or updated user journey test that validates the change in the context of user flows throughout the app. Note: we will continue to add user journey tests and associated documentation as we flesh out our user stories.
263+
264+
Eventually, we intend to add automated User Acceptance Tests (UATs) to the end-to-end test suite, which will be similar to the user journey tests, but will further verify that NPD meets the business requirements and user needs defined for each software stage. These are intended to support a test-driven development strategy, in which the business requirements are defined as code and the implementation is validated against those codified requirements. The automated UATs will not be required to be passing with each PR, but rather will give an indication of progress toward fulfilling feature, release, and/or product goals.
265+
266+
For additional information on our implementation of playwright and getting started with Playwright tests, please refer to the [README](/playwright/README.md) in the `playwright/` directory.
267+
268+
240269
### Coding Style and Linters
241270

242271
We require use of `ruff` to format all Python code and `prettier` to format all Typescript code.

0 commit comments

Comments
 (0)