If you're doing a straight forward unit test, with all class dependencies mocked out, then this becomes a plain Java question...
You either create a setter for IOrganizationDAO for testing purposes or start using constructor injection, and pass your mock in when you construct the service: public MyService(IOrganizationDAO orgDao) { this.orgDao = orgDao; } With the latter Tapestry will automatically find, resolve and use any constructors defined in your service, defaulting to the one with the most params. http://tapestry.apache.org/injection-in-detail.html Steve. On 5 September 2011 04:44, Ernesto Arroyo <earroyo...@yahoo.es> wrote: > This should be easy, but I can't figure how to do this. > > I have a service that has a dependency to a DAO, that I manage using > injection: > > @Inject > private IOrganizationDAO orgDao; > > As far as i know, tapestry uses the construction mechanism to injection, so I > have not a setter, tapestry does this through the constructor of the service. > > But now I want to do a unit test of this service, so I need to inject > manually a mock of the DAO, and I don't know how to do this. > Maybe I have to create a setter for the dependency, but I can't find any > example or documentation about this. > > private static IPacoService psrv; > > > @Test(enabled = true) > public void testGetAllOrganizations() { > // psrv.orgDao = new mockDAO(); ===> ???? > psrv.getAllOrganizations(); > // assert goes here > } > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org