Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#13227] Improve testing docs #13242

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

jasonqiu212
Copy link
Contributor

@jasonqiu212 jasonqiu212 commented Feb 22, 2025

Fixes #13227

Outline of Solution

  • Refactored Workflow: Development#Testing section to serve as a landing/entry section to all testing guides in TEAMMATES. The section only contain links to the individual How-to pages, while the exact details of how to run/create the tests are in the individual How-to pages.
  • Standardized naming and order of sections in how-to test pages. "How to run the tests" now always precedes "how to create the tests", since developers are more likely to run tests before writing any.
  • Group testing guide links together in sidebar menu

Copy link
Contributor

@mingyang143 mingyang143 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, I think it definitely improves the experience for a developer that wants to contribute via test cases. Great work!

Comment on lines 11 to -17
- It aims to ensure all components of the application work as expected, assuming its dependencies are working.
- This is done in TEAMMATES by using mocks to simulate a component's dependencies.

Frontend Unit tests in TEAMMATES are located in `.spec.ts` files, while Backend Unit tests in TEAMMATES can be found in the package `teammates.test`.
Frontend unit tests in TEAMMATES are located in `*.spec.ts` files and configured in `src/web/jest.config.js`.

Backend unit tests in TEAMMATES are located in the package `teammates.test` and configured in `src/test/resources/testng-component.xml`.

## Writing Unit Tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it looks fine.

Just a note—I typically run tests using IntelliJ’s built-in features rather than executing them manually using the terminal. In the test file, I just click the green test button and a task window pops up. In the task window, I will then select to run unitTests, since we’ve only been working with unit tests. The screenshot of the intellij window pop-up is attached below:
Screenshot 2025-02-27 at 2 06 27 PM

Would it be helpful to add comments for developers who primarily use IDE features? Maybe we could include guidance for popular IDEs like VS Code and IntelliJ.


</div>
- **Performance tests**: Evaluate the application's stability and responsiveness under expected, peak, and prolonged loads. See [Performance Testing](performance-testing.md).
- **Accessibility tests**: Ensure the application is accessible to users with disabilities. See [Accessibility Testing](axe-testing.md).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be good to also mention that docker has to be running to do testing?

Copy link
Contributor

@InfinityTwo InfinityTwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, great job on the improvements for the docs and the changes are very much welcomed!

npm run test
```

Most frontend component tests use [Snapshot Testing](snapshot-testing.md). To update snapshots, run the following command:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's useful to show that we need to run npm run test for Snapshot Testing. However, I think it would also be great if you could add a hyperlink in snapshot-testing.md in the "How do we use Snapshot Testing?" section to this part, or perhaps you can add instructions there on which commands we could use. It's a little confusing to newer developers because the given Jest docs link shows a different command (jest --updateSnapshot).

On a side note, it would help me greatly as well since I haven't found the right way to do so with my button PR 🤣


Test suite | Command | Results can be viewed in
---|---|---
`Component tests` | `./gradlew componentTests --continue` | `{project folder}/build/reports/tests/componentTests/index.html`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be useful to include a rough approximation of how long the tests will take to run (not just for this but for frontend as well)? I believe some of the tests takes ages to run and it might catch new developers off guard.

@@ -202,5 +248,3 @@ account.setEmail("[email protected]");
Student student = getTypicalStudent();
student.setName("New Student Name");
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be useful to add some helpful tips if the tests cannot run, for instance, there was a time where I couldn't run my test and I had to do ./gradlew clean build which then rectified the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve documentation on testing
4 participants