You need to be very careful about calling tester.injectInto() yourself because the superclass TapestryTest is already doing that for you. It contains this code: @BeforeClass(alwaysRun=true) public final void processInjectAnnotation() { tester.injectInto(this); }
So I would try removing the suite set-up from your TestifyBaseTest. Instead create a special class that is a subclass of TestifyBaseTest and has the suite setup in it and no actual tests. (This is as described in the documentation: http://tapestry.formos.com/nightly/tapestry-testify/#TestNG ). If that doesn't work, let me know and I'll take a more detailed look. - Paul Ben Gidley <b...@gidley.co.uk> wrote on 13/11/2009 16:41:56: > 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. > On Fri, Nov 13, 2009 at 4:00 PM, Augusto Rodriguez < > augusto.rodrig...@ioko.com> wrote: > > > 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"); > > } > > } --- This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. Please refer to http://www.db.com/en/content/eu_disclosures.htm for additional EU corporate and regulatory disclosures.