Info632 TD1
Info632 TD1
You are part of a team developing a new mobile application for a local restaurant. The
application aims to allow users create a basket of products and get promotions. As the
project progresses, your team has completed the initial development phase and is now
entering the testing phase.
Your Role:
As a software tester on the team, your role is crucial in ensuring the quality and reliability of
the application before it is released to the public. Your main responsibilities include:
1. Test Case Development: Based on the test plan, you will develop detailed test cases
covering various scenarios and functionalities of the application. This includes
positive tests to validate expected behavior and negative tests to uncover potential
bugs and vulnerabilities.
2. Execution of Test Cases: You will execute the test cases systematically, recording
the results and any issues encountered during testing. This will involve testing the
application on different devices, operating systems, and network conditions to
ensure compatibility and robustness.
To quickly get to grips with the project, the team asks you to take a copy of the project on the
following link. https://github.com/atemengue/software_testing_labs
Level 1: the first level will consist of writing simple tests for the intro.js, core.js files. the
aim is for you to get to grips with the vitest framework for writing application tests. it's
important to get members of the development team involved in building application tests.
1
1 – Introduction of Unit Testing
Automated testing involves writing code to verify that our software behaves as
expected. When done properly, it can significantly reduce the need for and cost of
manual testing. However, it cannot entirely replace manual testing, as certain aspects of
an application (e.g., aesthetics) are best assessed by human testers.
Test structures often follow the AAA (Arrange-Act-Assert) pattern. During the
Arrange phase, we set up the test environment. In the Act phase, we perform the
action to be tested, and in the Assert phase, we validate the outcome against our
expectations.
It's better not to write tests than to write bad tests; good tests should be easy to
maintain, reliable, and trustworthy.
To make your tests easier to maintain, give them clear names, focus on testing one thing
at a time, and keep them short and well-organized.
Effective tests are robust and don’t break easily when you make small changes to your
code, as long as the main functionality remains the same. To achieve this, test what the
code should do, not how it does it. In other words, test the behavior, not the
implementation.
Tight assertions can result in fragile tests that frequently break, while loose assertions can
lead to tests that consistently pass (false positives) and fail to provide us with enough
confidence that our software works. Striking the right balance between loose and tight
assertions is crucial for effective testing.
Tests should not be dependent on random values, current date/time, or any global
state, as this can cause them to give different results each time they are run.
2
2 – Core Unit of Unit Testing
● Using Matchers
A matcher is a function (or method) that allows us to make assertions about the
values produced during testing. Examples are toBe, toEqual, toBeNull, etc.
Check Common Matchers at the end of document.
Positive tests make sure that our application works under normal conditions, while
negative tests check how it handles unexpected or invalid input.
● Boundary Testing
Boundary testing is when we test how our software behaves in extreme situations
or at the edges of what it can handle.
● Parameterized Tests
Parameterized tests, also known as data-driven tests, are a testing technique where a
single test case is executed multiple times with different sets of input data or
parameters.
3
Common Matchers
Equality
toBe()
toEqual()
Truthiness
toBeTruthy()
toBeFalsy()
toBeNull()
toBeUndefined()
toBeDefined()
Numbers
toBeGreaterThan()
toBeGreaterThanOrEqualTo()
toBeLessThan()
toBeLessThanOrEqualTo()
toBeCloseTo()
Strings
toMatch()
Objects
toMatchObject()
toHaveProperty()
Arrays
toContain()
toHaveLength()