With so many moving parts, it becomes necessary to maintain the quality of the application at hand. Tests not only ensure correctness of the currently running code but they also help to ensure that adding new code doesn't break earlier code. Tests should be written not only for the happy path of what you expect to happen, but also for the negative cases. When writing tests, you would set up a case and then verify how the code behaves in an expected manner.
Unit testing would usually be done at a class level or for one or more related classes. This is often the subject for TDD, which influences the implementation of code to be more testable. When testing a single class having other dependencies, it is desirable to isolate it from its dependencies.
A common need is to test part of a code without having to worry about its dependencies. But the code should...