"Mark W. Shead" <mwsh...@fas.harvard.edu> wrote on 28/08/2009 21:36:55:
> Hm it appears to give me a copy of the registry, but not the same > instance that was used for testing the pages. I'm not too sure what you mean by "not the same instance that was used for testing the pages" but I'm going to guess that you are running some unit tests as well as some Selenium tests in the same process (test run). If that's true, then my code will create a TapestryTester for all the selenium tests but you may already have a TapestryTester that is shared for all your unit tests. The TapestryTester contains a complete IOC so you'll have two IOCs at the same time (which may or may not be a problem). There are two approaches to solving the problem. The first is to point to point the selenium tests at the TapestryTester that you already have. So, instead of this from my code: public abstract class MyAbstractIntegrationTest extends AbstractIntegrationTestSuite { protected static final TapestryTester tester = new TapestryTester("com.myapp.tapestry5", "app", PageTester.DEFAULT_CONTEXT_PATH); Use something like this instead: public abstract class MyAbstractIntegrationTest extends AbstractIntegrationTestSuite { protected static final TapestryTester tester = AbstractMyUnitTest. SHARED_TESTER; This has the advantage of creating just one IOC and sharing it - which is fine if you genuinely want the same IOC in both contexts. The second option is to use TestNG's lifecycle annotations to control the scope of each of the IOCs. I suspect organising the selenium and the unit tests as two separate "test"s in TestNG and using the @BeforeTest and @AfterTest annotations might be the right thing: @BeforeTest(alwaysRun=true) public void startup() { tester = new TapestryTester(...); } @AfterTest(alwaysRun=true) public void shutdown() { tester.shutdown(); } You'll need one set of the two methods for your Selenium tests and another set for your unit tests. However, I'm not a TestNG expert so I might be on the wrong track with this suggestion. - Paul --- 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.