In my project, I have two type of Service Class :
- The simple one, they are interface that use the DAOs
- The complicated one, are Rest Api Service
The Rest Service will make call to an API, and map the resulted JSON file as a mapped Object. Till here, there is no problem.
But, the thing is, that I had to make Unit Test of my RestApiService.
I have to explain one last thing, before asking my question. In my Rest API Service, I have multiple private methods that does some stuff specific to the API (such as finding request parameters from a file, sort them, filter them, etc...)
Should I make unit test of these private method? Or should I just make an Unit Test of the public method, that will call them?
On one hand, I feel like the Service should be like a contract, I ask it to give me mapped object and I should not care what it does.
On the other hand, I feel like, I should make unit tests of these 5 little private method.
The question How do you unit test private methods? is helpful, but in my situation, my Service contain multiple methods, and only one public method, should I still not unit test private methods?
EDIT
The second answer was actually the answer I needed, if my private method are so complex, I should create another Class for them. thanks