Hi!

I've spent some time now trying to get Testify working.
I do it according to the documentation, with an abstract
base class like this:

public abstract class AbstractPageTest extends TapestryTest {

    private static final String APP_PACKAGE = "com.expekt.web";
    private static final TapestryTester SHARED_TESTER =
        new TapestryTester(APP_PACKAGE, AppModule.class);

    public AbstractPageTest() {
        super(SHARED_TESTER);
    }

    @Override
    protected void setUpForAllTestMethods() throws Exception {
        MockitoAnnotations.initMocks(this);
    }
}

I then have a subclass with the JUnit 4 test:

public class GamesLauncherTest extends AbstractPageTest {

    @ForComponents @Mock
    private XyzManager xyzManager;

    @Mock
    private XyzConfig xyzConfig;

    // ...

    private void tellMockitoHowToMock() {
        when(xyzManager.getConfig()).thenReturn(xyzConfig);
        // ...
    }

    @Test
    public void testGamesLauncher() {
        tellMockitoHowToMock();

        // Now lets render the page and see that we got the right thing
        Document page =
           tester.renderPage(GamesLauncher.class.getCanonicalName());
        Assert.assertNotNull(page.getElementById("xyz"));
    }
}

What I get is runtime exceptions, such as this:

Caused by: java.lang.RuntimeException: Service id 'xyzConfig' is
not defined by any module.  Defined services: AccessDecisionManager,
... VirtualAssetStreamer.
        at
org.apache.tapestry5.ioc.internal.RegistryImpl.locateModuleForService(RegistryImpl.java:351)
        at
org.apache.tapestry5.ioc.internal.RegistryImpl.getService(RegistryImpl.java:318)
        at
org.apache.tapestry5.ioc.internal.ObjectLocatorImpl.getService(ObjectLocatorImpl.java:39)
        at
org.apache.tapestry5.internal.services.ServiceAnnotationObjectProvider.provide(ServiceAnnotationObjectProvider.java:35)
        at
org.apache.tapestry5.ioc.internal.services.MasterObjectProviderImpl$1.invoke(MasterObjectProviderImpl.java:48)
        at
org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:68)
        ... 188 more

We define our services in spring XML files, and @Inject them into our
pages, and this worries me quite a bit, since I can't see any examples
where Spring XML wiring has been mocked.

Or is that irrelevant?

Mats

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to