We implemented TDD by follwing this cycle:
Using this method, we made sure that all user acceptance criteria was met and efficiently produced high quality code.
Postman tests are integrated into the build and deployment workflows of the backend repository.
automated-api-tests:
runs-on: ubuntu-latest
needs: deploy-uat
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
npm install -g newman
- name: Run Postman tests
run: |
newman run ./tests/ci/safebank.postman_collection.json
We used GitHub status checks to ensure that only pull requests passing all tests can be merged into the main branch. See CI/CD documentaton here
Below are some examples of tests implemented for specific user stories, found in safebank-be/tests/functional/test_routes.py
:
User Story | Acceptance Criteria | Related Tests |
---|---|---|
215 Transfer Money | GIVEN a transfer request WHEN: - The source and target bank accounts exist - The source account belongs to the user - The amount to transfer is a non-negative number - The source account has sufficient balance THEN the transfer is made successfully |
test_transfer(...): Test that a transfer between accounts of a user is made successfully. test_invalid_transfers(...): Test that a transfer fails if the amount is negative or too large. test_transfer_between_users(...): Test that a transfer between two different users is successful. |
165 Manage User Accounts | GIVEN valid admin credentials WHEN accessing the user management portal THEN Admins can: - View a list of all users - View a list of all transactions - Create, update, and delete users |
test_create_user(...): Test that a user is created successfully. test_get_users(...): Test that a list of users can be retrieved. test_get_transactions(...): Test that a list of transactions can be retrieved. test_update_user(...): Test that a user’s information can be updated. test_delete_user(...): Test that a user can be deleted successfully. |
207 User Login | GIVEN valid user credentials WHEN a user fills out the login form THEN the system will authenticate the user and redirect them to their user page. If credentials are invalid, the user sees an error message. |
test_user_login(...): Test that a user can log in successfully. test_unsuccessful_user_login(...): Test that a user with invalid credentials cannot log in. |