Testing Guide
#
Our Believe & StrategyOur testing strategy is guided by the test trophy (By Kent C. Dodds):
Now that we are on the same page, let's go through our game plan.
#
Our BeliefWe want to empathize that we see tests as a critical part of well-written program. We understand that software of significance should be tested. This gives the developers great confidence that the software will work as expected.
#
Our Strategy- Static is a must (Supported by TypeScript & IDE integrations)
- Unit for critical components (Supported by Jest)
- Individual component rendering
- Function correctness
- Integration & E2E to ensure users experience what we build (Supported by
Cypress)
- Test cases are written per page & interactions permitted
- Test cases should verify both non-logged in users and logged in users behaviors
- System and Acceptance Test (Supported by QA & real users)
#
Test ArtifactsFor the purpose of accessment and documentation, we provide the following visual
test artifacts (Recorded test runs for end to end tests, test summary statistics
etc) as a proof of test execution and feedback. The details of the test cases
can be found in the folder cypress
and tests
respectively.
#
Screenshot of Unit Test Result#
Video recorded of a Cypress End-to-end test run @ milestone 3#
Gif of automated test results of a Github Action run @ milestone 3#
Past artifacts#
Video recorded of a Cypress End-to-end test run @ milestone 2#
Gif of automated test results of a Github Action run @ milestone 2#
Setup GuideAfter running yarn install
, you should be ready to start testing as all the
required dependencies are installed.
#
Static TestWe developed our application in TypeScript to take advantage of the ability to ensure type safety whenever possible. With the help of the IDE, any code that's loosely typed will be obvious to us and we aimed to eliminate the warnings by adding suitable type definitions to objects, variables and function declarations.
Along the same lines, we use Prettier + Eslint to enforce a consistent style
guide within the codebase. To run Eslnit, type in yarn lint
.
#
Unit TestWe use Jest and React testing library to perform unit tests. We aimed to include
unit tests to ensure low level but critical component logics are well tested. To
run tests, type in yarn test
.
With reference to Testing Recipes, our focus on front-end unit tests is on validating component rendering and function
correctness. For example in util.test.js
, the written tests cases verify the output of utility methods that involved datetime and notifications are as expected.
In index.test.js
, the test cases verify that rendering of individual components are successful.
#
End to End TestWe use Cypress to perform end user testing and validation of user interface.
Understand that UI changes can be more frequent and therefore hard to maintain,
we have decided to include E2E tests in the later stage. To use Cypress for test
development, start with npx cypress open
to open up the desktop client of
Cypress. Click on one of the written test to run it in the test browser. Any
changes saved on the currently running test file will trigger a rerun of the
test. You can also run npx cypress run
to run all tests headlessly.
#
Automated TestingOn top of verifying program correctness during development, we also ensure updates to the production build are always tested before merging. Please refer to our Continuous Integration section to find out more on how we perform testing with the help of Github Actions.
#
System TestTake the whole system and test it against the system specifications.
As we are the sole developers of the entire application, we will function as QA engineers to ensure the system is functioning properly and fails gracefully.
#
General tests#
Website requirements- The website should be preformat under reasonable load (500 users requesting
for the webpages within a span of 3 seconds)
- Input: load the homepage using Jmeter with the above specifications.
- Expected behavior: respond code 200 and report showing pages are loaded successfully.
#
User input error handling testsWe have implemented many user focused end to end tests in the quiz section and have also set up expiations to prevent users from entering corrupted or unwanted data. The following examples apply for both the creation and editing of whichever type is in question.
#
Create a postWe used help of external libraries such as Formik
and Yup
to verify and test
user inputted forms data. The current inputs are currently verified in the
following manner:
- title
- type must be one of the 2 existing tags and must be filled in.
- tags
- tags must be filled in and there has to be at least one tag.
- related question id (aka link question)
- related question id is optional and does not have to be filled.
- content
- content field must be filled in.
If any of the conditions are not met, a toast will show up on the top right of the screen and will prompt the user to fill in the necessary fields.
#
Create a quizWe used help of external libraries such as Formik
and Yup
to verify and test
user inputted forms data. The current inputs are currently verified in the
following manner:
- title
- type must contain a string and must be filled in.
- week
- week must be a possible week and must be filled in.
- tags
- tags are optional and no checks are run.
- questions
- Must have at least one question selected to make the quiz and must be filled in.
If any of the conditions are not met, a toast will show up on the top right of the screen and will prompt the user to fill in the necessary fields.
#
Create a questionWe used help of external libraries such as Formik
and Yup
to verify and test
user inputted forms data. The current inputs are currently verified in the
following manner:
- type
- type must be one of the 2 existing tags and must be filled in.
- question
- question must be a string and must be filled in.
- answer
- answer field must have at least two answers and at least one option must be marked as correct.
If any of the conditions are not met, a toast will show up on the top right of the screen and will prompt the user to fill in the necessary fields.
#
Acceptance TestTest the system to ensure it meets the user requirements.
Given below are instructions to test the application manually. In fact, we will write the equivalent integration tests such that what's described below will also be verified programmatically.
This section also serves as a guide for a potential user to see what are the testifiable requirements for the application. Note that the user guide will be the comprehensive source of all user permitted interactions.
#
Launch and exitInitial visit
- Visit the https://nus-connect.vercel.app/ of the website with a browser of your choice (Recommended: Google Chrome or Firefox)
- Expected: Shows the NUSConnect landing page with its Logo, Images & Text.
Subsequent use
- Refreshing or visiting NUSConnect on another browser tab.
- Expected: The website should still be in working conditions.
Exiting
- Close the browser or click the cross button to exit the webpage.
- Expected: Website should be closed normally.
#
LoginWithout login
- Prerequisites: The User has not logged in before or that the user has logged out of the application.
- Visit the https://nus-connect.vercel.app/ and any of the subpages within the website.
- Expected: The user remains logged out and is greeted by the login prompt
in the navigation bar and other parts such as the forum and quiz. Note
that the user will see "Anonymous" and a cat profile image on the
navigation bar as well as when in
/dashboard
. This is the default behavior for our application, such that anyone who is not logged in can still access certain features.
Logging in
- Click on the login button on the navigation bar or visit the login page at https://nus-connect.vercel.app/login. Select a social login provider and complete the login request.
- Expected: The user is redirected back to the website and is logged in.
Logged in
- Visit the https://nus-connect.vercel.app/profile page.
- Expected: The user will see his/her username as well profile picture retrieved from Github/Google. The navigation bar will also reflect the above user information.
Loggin out
- Prerequisites: The User has logged in.
- Click on
logout
by first clicking on the username on the navigation bar. - The user will be redirected to
https://nus-connect.vercel.app/login
page to confirm logout. Click on
Confirm Logout
. - Expected: The user is redirected to https://nus-connect.vercel.app/ and remains in logged out state.
#
Dashboard & AccountVisit Dashboard
- Visit https://nus-connect.vercel.app/dashboard.
- Expected: The user sees a personalized dashboard with relevant module information. The sidebar will also allow for navigation to other subpages.
Visit Badges
- Visit https://nus-connect.vercel.app/profile/badges.
- Expected: The user sees a list of available badges to be earned.
Visit Scoreboard
- Visit https://nus-connect.vercel.app/profile/scoreboard.
- Expected: The user sees a mock scoreboard that will later be a live record of the experience points of learners within the same module.
Visit Profile
- Visit https://nus-connect.vercel.app/profile.
- Expected: The user sees a page with some of the admin information about the profile.
#
ForumVisit Forum homepage
- Visit https://nus-connect.vercel.app/forum
- Expected: The user sees a list of existing posts on the left and some forum information on the right.
Visit a Forum Post
- Visit https://nus-connect.vercel.app/forum and click on any post on the left hand side.
- Expected: The user sees the expanded version of that post as well as all the replies that that author has.
Making a Forum post
- Visit https://nus-connect.vercel.app/forum/create-post.
- Prerequisites: The user must be logged in to make a post.
- Expected: The user sees the interface to create a new post towards the right hand side.
- Test case 1: Fill in the required fields, and click post.
- Expected case 1: A post is successfully posted and the user sees a success toast pop up at the top right of the screen.
- Test case 2: Leave the fields empty and click post.
- Expected case 2: A error message will pop up on the top right and text showing the required fields will show up. Post will not be posted.
Editing/deleting a Forum post
- Visit https://nus-connect.vercel.app/forum/.
- Prerequisites: The user must be logged in and the post to be edited must be posted by said user.
- Click on your post on the right hand side and click the edit button on the bottom left hand side of the main post.
- Expected: You will be given the option to edit your post and delete your post.
- Test case 1: Edit the fields you want to change, and click save.
- Expected case 1: The post is successfully updated and the user sees a success toast pop up at the top right of the screen.
- Test case 2: Click on delete post at the bottom left hand side of the post.
- Expected case 2: A prompt asking you if you want to delete your post will pop up and clicking delete will remove your post.
Replying a Forum post
- Visit https://nus-connect.vercel.app/forum and click on any post on the right hand side.
- Expected: User should see a reply box below the main post at the right hand side of the screen
- Test case 1: Fill in a reply and click post.
- Expected case 1: A reply is successfully created and the user sees a success toast pop up at the top right of the screen.
- Test case 2: Leave the fields empty and click post.
- Expected case 2: A error message will pop up on the top right and text showing the required fields will show up. Reply will not be posted.
Liking a Forum post or reply
- Visit https://nus-connect.vercel.app/forum and click on any post on the right hand side.
- Expected: User should see a like icon on the main post as well as the replies.
- Test case 1: Like a post or reply by clicking on the like icon.
- Expected case 1: A success toast is shown in the center bottom of the screen and the like button turns blue.
#
QuizVisit Quiz homepage
- Visit https://nus-connect.vercel.app/quiz
- Expected: The user sees a group of cards in the center of their screen with information about each quiz.
Visit a Question
- Visit https://nus-connect.vercel.app/quiz and click on any question in the center.
- Expected: A pop up should appear asking for confirmation and there should be an option to go into the question itself.
Making a question/quiz
- Visit https://nus-connect.vercel.app/quiz.
- Prerequisites: The user must be logged in to make a question.
- Expected: The user see the contribute a question button in the center of the screen. Users can click this to go into a interface to create an individual question / a quiz made of a few questions.
- Test case 1: Fill in the required fields, and click save.
- Expected case 1: A question is successfully saved and the user sees a success toast pop up at the top right of the screen.
- Test case 2: Leave the fields empty and click save.
- Expected case 2: A error message will pop up on the top right and text showing the required fields will show up. Question will not be posted.
Editing/deleting a question
in progress
Liking a quiz
- Visit https://nus-connect.vercel.app/quiz and click on the like button on any of the quiz questions.
- Expected: User should see a like icon on the main quiz as well as the replies.
- Test case 1: Like a quiz or reply by clicking on the like icon.
- Expected case 1: A success toast is shown in the center bottom of the screen and the like button turns blue.
#
Real User feedbackWe would like to thank our friends and fellow schoolmates for providing valuable feedback. Here we extracted out some comments given by the users:
Yes we feel that the team has accomplished the necessary requirements. The product seems very complete at this stage...
- Team NoteWorthy
...have a good functioning prototype.
- Team xiaoming eats yanyan
The team has done well in using various testing methods including automated testing.
- Project advisor