samedi 27 février 2016

Is it OK to use the actual service instead of mocking a service for unit testing in angularjs?

The scenario is very simple. I have a service say FooService. It depends on other services say "barService" and "utilityService". Lets assume that these 2 services(barService and utilityService) are just doing some calculations and return the results. They don't interact with any other external source. When I write unit test for FooService, I have 2 options
1) I can mock the dependencies (barService and utilityService)
or 2) I can use the actual services (barService and utilityService)

My question is since I am testing only FooService, it does not matter how I interact with other 2 services. Also instead of mocking everything for those 2 services, I can use the actual service itself. Is it a good practice for a test service to interact with the actual service? or It does not matter?

Aucun commentaire:

Enregistrer un commentaire