Optimizing The Code Coverage By Controlling Environmental Dependencies In Unit Testing
BINDU C.SHOBA, K. Khaja Baseer, V. RAVIKANTH · i-manager’s Journal on Software Engineering · 2018
Unit testing in object oriented development aims to determine whether the individual units are working as intended or not, which is accomplished by executing tests, and contains calls to unit under test (class or method) and verifies the output with expected one. Coverage criteria plays a significant role to decide if the unit testing was well performed or not. A successful unit test will have high amount of coverage. But often the execution of unit depends on environmental dependencies like file system, user interaction, database, and networks. Some techniques were developed to address these dependency issues. This paper addresses the networking interactions based on mocking approach, where some of the java.net Application Programming Interface (API) classes like InetAddress, Uniform Resource Locator (URL), Uniform Resource Identifier (URI), Socket, etc., are mocked. Then the work was evaluated against selected java programs, whose source code contains usage of java.net API classes. The results show improvement in the code coverage when unit testing is performed with network mocking.