It also called by component testing. Generally I is done by developer . However most of the case, Tester needs to write this.
UNIT TESTING is a type of software testing where individual units or components of a software are tested. The purpose is to validate that each unit of the software code performs as expected. Unit Testing is done during the development (coding phase) of an application by the developers
Image comes from Youtube