tapestry-testng creates the mocks as strict, meaning order of
invocation counts.  I've since decided this isn't a good idea, that it
just makes tests brittle (as in your example).

Add getMocksControl().checkOrder(false) at the top of your test.

On 6/5/07, Hugo Palma <[EMAIL PROTECTED]> wrote:
I'm using tapestry-testng 1.0.0-SNAPSHOT. Everything works fine if i
just create one mock object per test. But once i create two mocks it
seems that the second recorded behaviour doesn't get added to the
expected behaviour. So if i have this:

Messages messagesMock = newMock(Messages.class);
messagesMock.getMessage("company");
setReturnValue("success");

IPage whoWeAreMock = newMock(IPage.class);
whoWeAreMock.getPageName();
setReturnValue("company/WhoWeAre");

replay();
whoWeAreMock.getPageName();

i will get the following exception:

java.lang.AssertionError:
  Unexpected method call getPageName():
    getMessage("company"): expected: 1, actual: 0


If i use the following code, without using the TestBase API it works fine.

Messages messagesMock = org.easymock.EasyMock.createMock(Messages.class);
messagesMock.getMessage("company");
org.easymock.EasyMock.expectLastCall().andReturn("success");
org.easymock.EasyMock.replay(messagesMock);

IPage whoWeAreMock = org.easymock.EasyMock.createMock(IPage.class);
whoWeAreMock.getPageName();
org.easymock.EasyMock.expectLastCall().andReturn("company/WhoWeAre");
org.easymock.EasyMock.replay(whoWeAreMock);



Also, i can't seem to be able to get hold of the source code for
tapestry-testng(can't login on the svn javaforge repo) so i can't figure
out be myself what's wrong.
Appreciate any help..

Thanks.



--
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to