Wiki Spaces
Documentation
Projects
Resources
Get Help from Others
Q&A: Ask OpenMRS
Discussion: OpenMRS Talk
Real-Time: IRC Chat | Slack
Unit tests and integration tests are two types of software testing methods used in the development process to ensure the quality and reliability of software products.
Unit tests are focused on testing individual components or units of code, such as functions or methods, in isolation from the rest of the system. The purpose of unit tests is to verify that each unit of code behaves as expected and meets its specifications. Unit tests are typically automated and executed frequently during the development process to catch issues early and prevent regressions.
Integration tests, on the other hand, test the interactions and dependencies between different units of code or subsystems. Integration tests are designed to identify defects in the interfaces and interactions between components and to ensure that they work together correctly. Integration tests are usually performed after the individual units have been tested and are integrated into the larger system.
Unit and integration tests are essential parts of the software development process because they help ensure that the code behaves as expected, meets the requirements, and is reliable and maintainable over time. Unit and integration tests are essential parts of the software development process because they help ensure that the code behaves as expected, meets the requirements, and is reliable and maintainable over time.
According to the testing trophy introduced by Kent C. Dodds, Integration tests provide a high return on investment and are an essential part of a robust testing strategy. They verify large features or entire pages without using a real database, backend or browser. As unit & integration tests cover larger portions of the system, they are more likely to catch issues that other tests or developers may miss, making them an important component of testing. Therefore, investing more in integration tests compared to other kinds of tests can provide a greater overall benefit to the testing process.
For OpenMRS3 unit and integration tests, the following set of technologies is used.
The tests should have meaningful names and should be nested properly:
describe
must be the same as the component/page/hook/util we're testingdescribe
s must have the when
prefix (to indicate specific scenarios)it
must be a use-case sentence with the "should" prefixdescribe('useAuth', () => { describe('when user exists', () => { it('should return the user object', () => { // ... }); it('should log out user', () => { // ... }); }); describe('when user does not exist', () => { it('should return guest user', () => { // ... }); it('should destroy session on window close', () => { // ... }); }); });
Resources