You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Hugo Palma <hu...@gmail.com> on 2007/06/05 16:41:25 UTC
Can't create two mocks in same test with tapestry-testng
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.
Re: Can't create two mocks in same test with tapestry-testng
Posted by Hugo Palma <hu...@gmail.com>.
I had completely forgotten about that, crap....
Thanks for pointing it out Jesse.
Anyway, i finally remembered the anonymous login at javaforge, so i can
access the source now.
Jesse Kuhnert wrote:
> Don't forget
> http://tapestry.apache.org/tapestry4.1/tapestry-test/index.html-
> which is basically a duplicate of tapestry-testng + more tapestry
> specific
> base class stuff. I can make that change later today as I'd like it as
> well. (and maybe copy over those junit friendly changes I saw Howard
> make
> for T5 the other day)
>
> On 6/5/07, Howard Lewis Ship <hl...@gmail.com> wrote:
>>
>> I've unfortunately let those languish. There is an anonymous access
>> for the SVN repository (it's been discussed on this list before). I'm
>> very much bandwidth strapped, but I can look at updating the pom.xml
>> to generate source with the release which would not take time and
>> would help with this situation.
>>
>> If I ever get a little free time, I expect to set up more Tapestry
>> services at tapestry.formos.com, including our own SVN server.
>>
>> On 6/5/07, Hugo Palma <hu...@gmail.com> wrote:
>> > Cool, that solved it.
>> > Is there any where i can get the code of tapestry-testng from ? I
>> can't
>> > login in the javaforge svn repo, the anonymous login seems to be
>> > disabled. That would really help solving problems like these without
>> > having to bother you.
>> >
>> > Also, where should i request for new features or even submit
>> patches on
>> > this project ?
>> >
>> > Thanks again.
>> >
>> > Howard Lewis Ship wrote:
>> > > 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 <hu...@gmail.com> 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: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>
Re: Can't create two mocks in same test with tapestry-testng
Posted by Jesse Kuhnert <jk...@gmail.com>.
Don't forget http://tapestry.apache.org/tapestry4.1/tapestry-test/index.html-
which is basically a duplicate of tapestry-testng + more tapestry
specific
base class stuff. I can make that change later today as I'd like it as
well. (and maybe copy over those junit friendly changes I saw Howard make
for T5 the other day)
On 6/5/07, Howard Lewis Ship <hl...@gmail.com> wrote:
>
> I've unfortunately let those languish. There is an anonymous access
> for the SVN repository (it's been discussed on this list before). I'm
> very much bandwidth strapped, but I can look at updating the pom.xml
> to generate source with the release which would not take time and
> would help with this situation.
>
> If I ever get a little free time, I expect to set up more Tapestry
> services at tapestry.formos.com, including our own SVN server.
>
> On 6/5/07, Hugo Palma <hu...@gmail.com> wrote:
> > Cool, that solved it.
> > Is there any where i can get the code of tapestry-testng from ? I can't
> > login in the javaforge svn repo, the anonymous login seems to be
> > disabled. That would really help solving problems like these without
> > having to bother you.
> >
> > Also, where should i request for new features or even submit patches on
> > this project ?
> >
> > Thanks again.
> >
> > Howard Lewis Ship wrote:
> > > 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 <hu...@gmail.com> 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: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
Jesse Kuhnert
Tapestry/Dojo team member/developer
Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
Re: Can't create two mocks in same test with tapestry-testng
Posted by Howard Lewis Ship <hl...@gmail.com>.
I've unfortunately let those languish. There is an anonymous access
for the SVN repository (it's been discussed on this list before). I'm
very much bandwidth strapped, but I can look at updating the pom.xml
to generate source with the release which would not take time and
would help with this situation.
If I ever get a little free time, I expect to set up more Tapestry
services at tapestry.formos.com, including our own SVN server.
On 6/5/07, Hugo Palma <hu...@gmail.com> wrote:
> Cool, that solved it.
> Is there any where i can get the code of tapestry-testng from ? I can't
> login in the javaforge svn repo, the anonymous login seems to be
> disabled. That would really help solving problems like these without
> having to bother you.
>
> Also, where should i request for new features or even submit patches on
> this project ?
>
> Thanks again.
>
> Howard Lewis Ship wrote:
> > 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 <hu...@gmail.com> 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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Can't create two mocks in same test with tapestry-testng
Posted by Hugo Palma <hu...@gmail.com>.
Cool, that solved it.
Is there any where i can get the code of tapestry-testng from ? I can't
login in the javaforge svn repo, the anonymous login seems to be
disabled. That would really help solving problems like these without
having to bother you.
Also, where should i request for new features or even submit patches on
this project ?
Thanks again.
Howard Lewis Ship wrote:
> 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 <hu...@gmail.com> 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.
>>
>
>
Re: Can't create two mocks in same test with tapestry-testng
Posted by Howard Lewis Ship <hl...@gmail.com>.
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 <hu...@gmail.com> 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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org