Unit testing is the process of testing a single functionality in the code at a time. In unit testing, the developer ensures that the functionality is working correctly according to business logic. We will use JUnit for unit testing.
JUnit is an automation testing framework which provides numbers of TestRunners
that can automate the execution of any Java class that extends from TestCase
. It facilitates the testing of the expected behavior of a method as a unit. The developer can write test cases for all the functions in the code. Whenever a change occurs in the functionality, causing it to behave differently than expected, it can be easily identified and fixed as well. JUnit 4 supports annotation-based programming so instead of getting extended from the TestCase
, the developer can use annotation-based programming as well.