Unit testing is used to test a small piece of code and verify that it will do what we expect it to do. This means we test the function or procedure at hand, but not the surrounding infrastructure. Unit testing is a common way to ensure quality by giving confidence on each part of the system individually, for example: Classes, Methods and Sub procedures are tested with unit tests.
Unit testing is an essential part of any developer’s workflow. Unit tests allow developers to be confident that the code they write and changes they make to existing code will not break the applications being developed. They can also be used to ensure that new features are working as intended before being released.
Unit testing is the first step to testing the code which the developer performs. It tests the happy path and the essential software/code/logic requirement. For example, if the code is written to add two numbers, then the unit test will add two numbers and ensure the answer is correct. However, QA testing will not be limited to that. The quality engineer will ensure that all the happy/unhappy paths are covered. The application is tested as it will be used in the real life.