---
# System prepended metadata

title: Automated testing how-to

---

# Automated testing how-to

Automated testing is required for at least XX% of your user stories onwards. You must have at least 3 tests (e.g. 3 talend API queries or 3 unit tests) per user story, preferrably each test should cover each acceptance criteria.

Generaly this is how you will test each user story:

- **API endpoint stories**: e.g. create a post, update a profile, delete a post, view a post, view feed. You can test these using [Talend API Tester (Free Edition)](https://chrome.google.com/webstore/detail/talend-api-tester-free-ed/aejoelaoggembcahagimdiliamlcdmfm?hl=en) or [Postman](https://www.postman.com/)
- **Algorithm stories**: when most of the story is implemented in a function, you can write unit tests for the function.
  - For example let's say you have a method `getFeed(user: UserId) -> FeedId[]`, which takes a user id and returns posts for their feed based on their reported interests. You can create some dummy users and dummy posts, and test that `getFeed` with the dummy user ID returns the proper posts.
  - Another example: let's say you have search functionality, and as part of that you have written a function `matchPriority(query: string, post: Post) -> number` which takes a query and post and returns how highly it should be ranked in the search queue (e.g. the function may return `5` if the query exactly is the post title, `3` if the query is contained within the title, and `1` if it is contained within the text). You can write a unit test which calls `matchPriority` with various queries and posts and checks the output against hard-coded values.
  - You can write unit tests for using [JUnit](https://junit.org/junit5/) (Java), [unittest](https://docs.python.org/3/library/unittest.html) (Python), or [Jest](https://jestjs.io/) (JavaScript) - ask your project coordinator for other languages
- **Stories pertaining to UI / page load / responsiveness**, e.g. the app adapting to desktop or mobile. You probably will only use manual tests for these since automated testing them is less straightforward. However there are tools available, e.g. [Core Web Vitals](https://web.dev/vitals/) which tests loading time.

## Resources

[Talend API Tester (Free Edition)](https://chrome.google.com/webstore/detail/talend-api-tester-free-ed/aejoelaoggembcahagimdiliamlcdmfm?hl=en)

[Postman API testing by example](https://testfully.io/blog/postman-api-testing/)

[JUnit Guide](https://junit.org/junit5/docs/current/user-guide/)

[Python unittest](https://docs.python.org/3/library/unittest.html)

[Jest Guide](https://jestjs.io/docs/getting-started) (if you are using JavaScript but not npm, contact your project coordinator)

---

If you have any additional questions about automated testing, the tools, or how to start using them, contact your project coordinators or ask on Piazza.
