May 2018
Intermediate to advanced
300 pages
7h 35m
English
Unit tests should be easy to set up and decoupled from any direct or external dependencies. The external dependencies should be mocked using a suitable mocking framework. Appropriate object setup should be done in setup methods or test class constructors.
Avoid redundant codes that can clog the tests and ensure the tests contain only codes that are relevant to the methods being tested. Also, tests should be written for units or methods. For example, writing tests for class getters and setters might be considered too trivial.
Lastly, good unit tests should have good code coverage. All execution paths in a method under test should be covered and all the tests should have defined criteria that ...