Injecting services into tests

Sometimes, particularly for internal integration tests, you will want to access services from the IOC registry in your tests. Simply use the usual IOC annotations on fields in your test and Testify will inject the services at the start of the test setup.

public class MyTest extends AbstractMyApplicationTest {

    @Inject
    MyService service;

    @Inject
    @Service("serviceId")
    MyNamedService namedService;

    public void testElementIsOnPage() {
        service.doSomething();
        Document page = tester.renderPage("mypage");
        assertNotNull(page.getElementById("myid"));
    }
}