Dear Tapestry Users,

we started to use TDD (Test Driven Development) with Tapestry 5.2
in order to observe the rules of TDD we need to mock the following services as 
well:-org.slf4j.Logger
-org.apache.tapestry5.ioc.Messages
the @ForComponents annotation had no effect in case of this 2 services
is there any way to mock them, to check their invocations?
thanks in advance
Izolda ps: some part of the code @RunWith(JMock.class)
public class MyPageTest extends AbstractTest {
    @ForComponents
    private Logger logger;
    @ForComponents
    private Messages messages;
    private Mockery context = new JUnit4Mockery();

    public void doSetUp() {
        logger = context.mock(Logger.class);
        messages = context.mock(Messages.class);
    }

    @Test
    public void testUserLoggedIn() {
        // TEST FIXTURE
        context.checking(new Expectations() {
            {
                oneOf(logger).debug("user logged in");
                oneOf(messages).format("welcome", "Black Smith");
                will(returnValue("Hello Black Smith!"));
            }
        });
        // Excercise sut
        Document document = tester.renderPage("MyPage");
        // TEST ASSERT
        assertNotNull(document);
        assertSpan("spamWelcome", "Hello Black Smith!", document);
    } java.lang.AssertionError: not all expectations were satisfied
expectations:
  expected once, never invoked: logger.debug("user logged in"); returns a 
default value
  expected once, never invoked: messages.format("welcome", ["Black Smith"]); 
returns "Hello Black Smith!"

Reply via email to