Hello!

My team and I were discussing different ways of bettering our unit tests 
and one topic that came up is, 'Are we unit testing correctly?' Typically, 
each `describe` block represents a single function in our 
controller/service/whatever and each `it` block is meant to test a certain 
aspect of that function. Well, one issue we ran across is how can we 
properly test private functions.

We feel we shouldn't need to expose them on the view/model just have access 
to them for testing. I did some research and the answers I found didn't sit 
right with me for some reason. Some people were saying there really isn't a 
way to test the private functions directly and that by testing the public 
functions calling those private functions, we were implicitly testing them. 
That doesn't seem like proper unit testing to me. One other answer I found 
was to pull out the private functions into services/factories so they can 
be reused and tested properly. The problem with this, for us at least, is 
that we have about 180 controllers in our application and many of them 
share the same type of functions. For example, most have a `handleSave` 
function that ultimately, across the controllers, accomplish the same task, 
but get there differently. Pulling our `handleSave` functions out into a 
single service would make that service HUGE in order to allow it to handle 
all possible save scenarios across the controllers. On the other hand, 
giving each `handleSave` function it's own service, would create a TON of 
services and that would still make the `handleSave` function public.

So, I guess I just want to see what everybody else is doing and how they 
are handling this. 

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to