I have a class A as follows
public class A{
@Inject
private B b;
public String doStuff(){
//Do some stuff, which utlizes b
}
}
I know how to mock A and B. I am not clear how to strub A.b with my
mock B. Can somebody please help me?
Thanks in advance.
I would do either of:
- make the 'b' field package-protected
- or add a setter for the 'b' field
so that I can set it from the test...
No need for any mocking.
Cheers,
Szczepan Faber
> --
> You received this message because you are subscribed to the Google Groups "mockito" group.
> To post to this group, send email to moc...@googlegroups.com.
> To unsubscribe from this group, send email to mockito+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mockito?hl=en.
>
>
http://blog.james-carr.org/2009/12/29/express-your-dependencies/
Thanks,
James
Though you might need to extend it a bit to understand the @Inject
Annotation. It might only know @EJB, but it should be no problem to
add @Inject as well.
Greetings,
Malte