differences between unit testing and end to end testing code example

Example: end to end testing vs unit testing

End to end testing is the process of testing
a piece of software from start to finish as
it will be used by the actual users. 
For example a web application, you would start a browser,
navigate to the correct URL, use the application
as intended, and verify the behavior.


UNIT TESTING is a  software testing where individual
units or components of a software are tested.
The purpose is to validate that each unit of the 
software performs as designed.