Hi.

This question isn't directly about guice but since there's multiple
smart people on this list I thought I'd ask here.

Guice uses reflection and types and this kinds of nice things
internally and I assume there's unit tests written to test the code
that handles this... But how... I'm writing code myself that requires
me to do reflection (looking at annotations and stuff like that). But
how do I unit test it?

Example:
        public void method(Class<?> aClass) {
                final MyAnnotation annotation = aClass.getAnnotation
(MyAnnotation.class);
                return annotation != null;
        }

how do I write tests that that confirm this behavior. The normal way I
would do this is with mocks. But Class is final so that don't quite
work.

The only way I can think of is to create a class that is annotated
this way and one that is not and use them.  The problem with this is
that the class is not connected to the test and I have to look at two
places to see what the test does (with mocks I could see it all in the
test method). Also it clutters my test code with lots of dummy
classes.

Have I just gotten lazy when I can normally mock all dependencies or
is there a way around this?




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to