diff --git a/reports/final-report-34.md b/reports/final-report-34.md index 50079e1..d5e916c 100644 --- a/reports/final-report-34.md +++ b/reports/final-report-34.md @@ -123,6 +123,28 @@ Search results are displayed in a card format, including user and event informat ### 3. Tests +We have unit tests for the backend. We used `jest` and `supertest` to implement these tests. To run the tests, you can use the following command: + +```bash +cd server +npm test +``` + +Note that since the unit tests involve login, directly running `npm test` may result in test failures since the port is occupied. To avoid such issues, you may use the following command instead: + +```bash +cd server +npm test src/test/user.test.js +npm test src/test/event.test.js +npm test src/test/comments.test.js +``` + +The cover rate of `user.test.js` is 38%, `event.test.js` is 42%, and `comments.test.js` is 41%. + +The unit tests only check the basic functionality of the backend, and most of the tested functions are `GET` or `DELETE`. To fully ensure the correctness of the backend, we also conducted manual tests. + +Our manual tests used the api-doc that were automatically generated by `swagger`. We firstly login as admin or an ordinary user, then we manually fill in the parameters and click the `Try it out` button to test the correctness of the backend. We tested all the APIs in the api-doc, including `GET`, `POST`, `PUT`, and `DELETE`. We also tested the APIs with invalid parameters to check the error handling of the backend. + ### 4. Build ### 5. Deployment