akochnev <akoch...@gmail.com> wrote on 31/01/2010 11:26:53:

>    The next thing I'm trying to work out is use  Testify for unit-like
> testing. The idea was that I could possibly instantiate the page class
> myself (e.g. w/o having to ask the tester to render the page), inject 
the
> dependencies (using tester.injectInto(pageInstance) ) that are needed 
for a
> particular method and then just invoke the method.

The injectInto() method is designed to populate fields in a test *before* 
any of the setup is done - so it doesn't really expect to work with the 
@ForComponents annotations.

You could let Tapestry do the instantiation of the page for you. I think 
this will work (although it uses internal services so it might work now 
but not in a future Tapestry version):

    @Inject
    private RequestPageCache cache;

    public void test() {
        StupidPage page = 
(StupidPage)cache.get("mypages/stupidPage").getRootElement().getComponent();
        page.myMethod();
    }

This potentially has the advantage that all the transformations have been 
done on the class - so it behaves more like the page actually will.

Out of interest, what kind of tests need the instance of the page class? I 
haven't felt the need so far so I wonder if I'm missing out on something 
:-)

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.

Reply via email to