Open GoogleCodeExporter opened 9 years ago
Actually instead of that, we could just pass use injection strategy, this a bit
like higher level. Because we don't want Mockito to be a DI framework. Passing
a strategy does seem to be more relevant.
We could write something like :
@InjectMocks(applying = ConstructorInjection.class)
@InjectMocks(applying = YourCustomInjectionStrategy.class)
Original comment by brice.du...@gmail.com
on 17 Feb 2012 at 10:14
The only issue with this way of configuring the strategy in the annotation is
the custom strategy itself cannot have configurable state as the annotation
members are required to be constants by language design.
Original comment by brice.du...@gmail.com
on 17 Feb 2012 at 10:18
I wonder what's the use case. Do you have a need for separate injection
strategies in different tests?
Original comment by szcze...@gmail.com
on 18 Feb 2012 at 10:00
We discussed it a bit in this thread on the mailing list :
http://groups.google.com/group/mockito/browse_thread/thread/bdec413595d4a57b/37a
379ea7f0b9105
Marek and his mockaroo project might be interested by this feature for example.
However we could avoid this annotation injection and use the ServiceLoader
alike stuff ?
Original comment by brice.du...@gmail.com
on 19 Feb 2012 at 1:58
I'm not opposing the feature - just thinking on what would be best for the
user. The necessity to decide on the kind of injection per test feels a bit
awkward. It feels that making the injection smarter or make it easily
configurable per project is the way to go. Just loud thinking :)
Original comment by szcze...@gmail.com
on 20 Feb 2012 at 1:56
Mmmh I think it should be configurable per test. If someone want to ensure
constructor injection on specific objects, it seems like the right thing to do.
Plus it allows to use a custom strategy, for things like '@Collaborator2'.
About project wise configuration : using MockitoConfiguration or a
ServiceLoader could be the way to go.
Original comment by brice.du...@gmail.com
on 20 Feb 2012 at 2:20
Original comment by brice.du...@gmail.com
on 3 Sep 2012 at 10:00
Original issue reported on code.google.com by
brice.du...@gmail.com
on 8 Nov 2011 at 2:28