You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Angelo Chen <an...@yahoo.com.hk> on 2008/01/21 03:53:11 UTC

T5: TapestryTestCase newbie

Hi,

I'm trying to use TapestryTestCase, here is a simple case that I don't know
how to handle:

here is the object under test:

public class MyServiceImpl implements MyService {

    final private Session session;
    public MyServiceImpl(Session session) {
        this.session = session;
    }

    public void appendUsr() {
        Usr usr = new Usr();
        session.save(usr);
    }
}

and here is the test code:

public class MyServiceImplTest extends TapestryTestCase {

    @Test
    public void test() {
        Session session = newMock(Session.class);
        MyServiceImpl service = new MyServiceImpl(session);

        expect(session.save(new Usr())).andReturn(null); // is this correct
way to specify expectation?

        replay();
        service.appendUsr();
        verify();
    }
}

I always get :

Unexpected method call Session.save...

Any idea what's wrong here? Thanks,

A.C.



-- 
View this message in context: http://www.nabble.com/T5%3A-TapestryTestCase-newbie-tp14990341p14990341.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: T5: TapestryTestCase newbie

Posted by Angelo Chen <an...@yahoo.com.hk>.
hi,

found the solution, should have been:

expect(session.save(anyObject())).andReturn(null);

another question is, TapestryTestCase has replay(), verify(), but don't have
reset(), how to reset mock objects under TapestryTestCase? 

Thanks,

A.C.




Angelo Chen wrote:
> 
> 
>         expect(session.save(new Usr())).andReturn(null); // is this
> correct way to specify expectation?
> 
>   
> 

-- 
View this message in context: http://www.nabble.com/T5%3A-TapestryTestCase-newbie-tp14990341p15011702.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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