Testing Unit Tests - AutolabJS/autolabcli GitHub Wiki

What is Unit Testing?

Unit Testing is a level of software testing where individual units/ components of a software are tested. The objective of Unit Testing is to isolate a section of code and verify its correctness.

Ideally, each test case is independent from the others. Substitutes such as method stubs, mock objects, and spies can be used to assist testing a module in isolation. These topics will be covered in more detail in the Sinon section.

Mocha Testing framework is used in this project to write integration tests.

Benefits of Unit Testing

  • Unit testing increases confidence in changing/ maintaining code. If good unit tests are written and if they are run every time any code is changed, we will be able to promptly catch any defects introduced due to the change. Also, if codes are already made less interdependent to make unit testing possible, the unintended impact of changes to any code is less.

  • Codes are more reusable. In order to make unit testing possible, codes need to be modular. This means that codes are easier to reuse.

  • Development is faster. If you do not have unit testing in place we might have to manually test some functionalities of the code. But unit tests enable us to automatically test different scenarios.

  • The cost, in terms of time, effort and money, of fixing a defect detected during unit testing is lesser in comparison to that of defects detected at higher levels.

References and See also