ace-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcel Offermans <marcel.offerm...@luminis.nl>
Subject Re: Testing DependencyManager services
Date Mon, 07 Dec 2009 09:35:43 GMT
Hello Toni,

On Dec 7, 2009, at 10:25 , Toni Menzel wrote:

> maybe i am missing something, but how do i unit test Services that have
> dependencies which are injected (usually) by the DependencyManager ?
> Is there anything else than injecting those mocks via manual reflection ?

We have a utility class (called TestUtils) that has various methods to inject instances. It
allows you to inject an arbitrary instance, a null object or even an adapter that allows you
to "partially" implement any instance (and have the rest of the methods handled like a null
object).

> On the other hand, usually the approach is to support constructor injection
> instead of field injection. Any thought in this direction at
> DependencyManager ?

Constructor injection is a static injection, so it is currently not explicitly supported (most
instances will have their members injected at runtime, not just once when constructed). Then
again, there is nothing preventing you from adding a constructor with parameters either. With
the utilities above, I don't think it's really necessary though.

> Even if not, i would propose giving those services a catch-all constructor
> which can be used in out of container scenarios (testing).
> (would be great if dependencymanager could live with that alone).

What exactly do you mean by a "catch-all constructor"?

Greetings, Marcel


Mime
View raw message