Christian Edward Gruber <christianedwardgru...@gmail.com> wrote on 27/07/2009 11:07:41: > I think that @BeforeMethod is a better one to key off-of. If > singleton-scoped objects are the only ones being injected, then > @BeforeClass makes sense, but if you're testing per-request or per- > session objects, then it's best to use @BeforeMethod, since you may be > setting state on these which needs to be fresh for each test.
As I understand the Tapestry IOC, it shouldn't make any difference. Generally, service objects are actually proxy objects; with non-singleton scopes the proxy object is responsible for forwarding calls to the correct instance of the service. For example, to quote the documentation, "With perthread, the service proxy will delegate to a local service instance that is associated with the current thread. Two different threads, invoking methods on the same proxy, will ultimately be invoking methods on two different service instances, each reserved to their own thread." See "Defining Service Scope" on: http://tapestry.apache.org/tapestry5.1/tapestry-ioc/service.html This ingenious feature is what allows Tapestry IOC to inject a per-thread service into a singleton service and have that work correctly. If you are setting up state that you want to be fresh for each test, then you should consider using Testify's pertest scope: http://tapestry.formos.com/nightly/tapestry-testify/#Per-test_scope 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.