views:

35

answers:

1

I usually try to minimize testing with Selenium and maximize the usage of plain old back-end testing (JUnit, mocking). With Tapestry I am finding it hard to test pages and components in the latter way due to the "magic" that occurs with the callback functions.

Have you been able to solve this? Or are you just using Selenium for the whole web layer (pages, components)?

+1  A: 

According to the Tapestry documentation using PageTester is the appropriate way to do unit testing of Pages and Components : http://tapestry.apache.org/tapestry5/guide/unit-testing-pages.html

But this seems similar to HtmlUnit style web testing as the interaction happens through a web browser like interface and not through the interface of the Page or Component.

Edit

I just tried a simple unit test for pages and it works quite well :

public class FooPageTest extends AbstractServiceTest{

    @Autobuild
    @Inject
    private FooPage fooPage;

    @Test
    public void setupRender(){
        fooPage.setupRender();
    }

}

AbstractServiceTest provides a test runner which provides the Tapestry dependency injection to the unit test class. With Autobuild you get the @Inject dependencies of the FooPage satisfied and for the component injections and @Property annotated elements you will need to figure out something else.

Timo Westkämper