Augusto, I just fixed this by making the 'TapestryTester' not static. THis removes the issue. However this does seem to defeat some of the point of testify as we now have a lot slower tests are we will be initialising the tester for each test.
Ben Gidley www.gidley.co.uk b...@gidley.co.uk On Fri, Nov 13, 2009 at 4:00 PM, Augusto Rodriguez < augusto.rodrig...@ioko.com> wrote: > Hi All, > > I'm using testify to test my pages, but I can only run one test > successfully and all the other tests, whether they are in another class > or in the same class, fail with the message: > Found more than one object marked as @ForComponents of type > uk.co.test.services.PageInformation > > > It looks like testify is inserting the mock "pageInformation" two times > in the IoC container. > > I don't know if this is related to how I'm using TestNG annotations > and/or using @ForComponent in the parent class. I've tried to play a bit > with the annotations, for example I annotated TestifyBaseTest.suiteSetup > with @BeforeClass, @BeforeTest and @BeforeMethod without success. I've > also tried to move the attributes annotated with @ForComponents to the > subclasses, but it didn't work too. I have copied a bit of my code below > as reference. > > > Thanks a lot! And sorry for the long email. > > Cheers, > Augusto > > > Base test class: > > Public class TestifyBaseTest extends TapestryTest { > private static final TapestryTester SHARED_TESTER = new > TapestryTester("uk.co.test.ux", TestModule.class ); > > @ForComponents @Mock protected PageURLResolver pageURLResolver; > @ForComponents @Mock protected PageInformation pageInformation; > > public TestifyBaseTest() { > super(SHARED_TESTER); > } > > @BeforeSuite(alwaysRun=true) > public void suiteSetup() { > tester.injectInto(this); > } > > @Override > protected void setUpForAllTestMethods() throws Exception { > MockitoAnnotations.initMocks(this); > } > } > > > Test: > public class SimpleTest extends TestifyBaseTest { > > @BeforeMethod(alwaysRun=true) > public void setup() { > //stub some method calls > } > > // this test passes. > @Test(groups="fast") > public void canRenderProgrammeTitle() throws > PageNotFoundException { > Document page = tester.renderPage("test"); > } > > // this test throws an exception with the message "Found more > than one object marked as @ForComponents of type > uk.co.test.services.TestService". > @Test(groups="fast") > public void canRenderProgrammeTitle() throws > PageNotFoundException { > Document page = tester.renderPage("test"); > } > } > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > >