All of us have some utility classes, which contain only static methods, for usage from different sources. Now, there can be two approaches which can be taken towards testing this piece of code.
Approach 1:
Have separate unit tests for utility classes. Wherever they are being called, mock out their interaction using some test framework which has provision for it, such as PowerMock. This essentially treats the utility class as a separate component of the system, which needs to be individually tested out and maintained.
Approach 2:
Do not write unit tests for utility classes. However, tests which are written for your other core classes which interact with this utility class, let that interaction happen, which will intrinsically ensure that the code written in this utility class is properly tested for different usecases. If something breaks, the tests for other components should be able to catch it.
Please share your thoughts on which approach is preferable, or if there is some other manner in which people go about this.