Hi Yury, I don't really understand what you are trying to actually test with your test.
Anyway, let me explain why you are seeing the behaviour that you are seeing. In Testify, you create the IOC registry and that registry remains constant throughout all the tests. Testify does not let you mock or replace a service. So therefore, when you call tester.getService() it will return the service from the registry. What Testify does is change the semantics of @Inject so that it prefers to look up objects from a pool of test objects and that pool of objects is populated by @ForComponents and is cleaned up for every test. This change in semantics means that you can render a page and control the objects that get @injected into the page and its components - and that control includes using mock objects. Hope that helps. If not, let me know a bit about what you are trying to achieve with your test. Paul Yury Luneff-2 wrote: > > hello! > > I'm experiencing a sort of difficulty coping with testify. > > I have the following: > > public class ServTest extends TapestryTest { > private static final TapestryTester SHARED_TESTER = new > TapestryTester("serv", "app", "src/main/webapp"); > > public ServTest() { > super(SHARED_TESTER); > } > } > > public class SmokeTest extends ServTest { > @ForComponents HttpServletRequest request; > > protected void setUpForAllTestMethods() { > request = createNiceMock(HttpServletRequest.class); > expect(request.getServerName()).andReturn("localhost"); > expect(request.getServerPort()).andReturn(8080); > expect(request.getContextPath()).andReturn("serv"); > replay(request); > } > > @Test > public void smoke() { > assertEquals(request.getServerName(), "localhost"); > HttpServletRequest rs = > tester.getService(HttpServletRequest.class); > assertNotNull(rs); > assertEquals(rs.getServerName(), "localhost"); > ... skipped from here to the end ... > > Last assert fails, I can not understand why. > @Inject works for tests, but not the @ForComponents. Or am I using it > in a wrong way? > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > > -- View this message in context: http://old.nabble.com/testify-forcomponents-problem-tp26838462p26856206.html Sent from the Tapestry - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org