|
From: Steve F. <st...@m3...> - 2004-01-07 23:11:37
|
Hello mockistas. We (Steve & Nat) have just spent a semi-productive session designing an API for "lenient mode" mock objects. In lenient mode a mock will return default values from unexpected invocations instead of throwing a test failure. But then we decided that it was a bad idea and deleted all the code. Lenient mode can mask errors and make errors fail slow instead of fast. In fact, Nick Robinson has just complained about this on the nmock list. There is some mechanism underneath to support default values for people who want to pop in their own default stub, but this is not yet exposed properly. What do people think about lenient mode? Cheers, Nat & Steve. |
|
From: Nick R. <nic...@ya...> - 2004-01-08 07:38:42
|
I personally can see the benefit of the lenient mode, but IMO it should have to be "switched on", and be in switched off mode by default. This is similar to my comments about the Strict property. However, if there was documentation with NMock, which was accompanied with a few use scenarios (showing the use of Strict), such problems I witnessed may not have happened. Thanks, nick.robinson site : www.fromconcept.co.uk blog : www.fromconcept.co.uk/weblog.aspx > -----Original Message----- > From: nmo...@li... > [mailto:nmo...@li...]On Behalf Of Steve > Freeman > Sent: 07 January 2004 23:13 > To: JMock Dev > Cc: nmo...@li... > Subject: [Nmock-general] Strict vs Lenient mode for mock objects > > > Hello mockistas. We (Steve & Nat) have just spent a semi-productive > session designing an API for "lenient mode" mock objects. In lenient > mode a mock will return default values from unexpected invocations > instead of throwing a test failure. > > But then we decided that it was a bad idea and deleted all the code. > > Lenient mode can mask errors and make errors fail slow instead of fast. > In fact, Nick Robinson has just complained about this on the nmock list. > There is some mechanism underneath to support default values for people > who want to pop in their own default stub, but this is not yet exposed > properly. > > What do people think about lenient mode? > > Cheers, > Nat & Steve. > > > ------------------------------------------------------- > This SF.net email is sponsored by: Perforce Software. > Perforce is the Fast Software Configuration Management System offering > advanced branching capabilities and atomic changes on 50+ platforms. > Free Eval! http://www.perforce.com/perforce/loadprog.html > _______________________________________________ > Nmock-general mailing list > Nmo...@li... > https://lists.sourceforge.net/lists/listinfo/nmock-general > |
|
From: Nat P. <nat...@b1...> - 2004-01-08 12:03:06
|
Here's what we are envisaging.
A Mock* has a set of invocation mockers and a default stub that is used to
provide behaviour for an invocation that doesn't match against any
invocation mocker.
By default the default stub signals a test failure.
The user will be able to set the default stub to change the default
behaviour of the mock.
If they change it to a DefaultResultStub then they will get a lenient mode.
They can set up the DefaultResultStub to handle their own classes and share
a single DefaultResultStub among multiple mock objects so that they all have
the same default behaviour.
Code would look like:
public void setUp() {
DefaultResultStub defaults = new DefaultResultStub();
defaults.addDefaultResult( Date.class, new Date(-1L) );
defaults.addDefaultResult( Point.class, new Point(0,0) );
mock = new Mock( MockedInterface.class );
mock.setDefaultStub( defaults );
}
What do people think?
--------
* Actually the InvocationDispatcher inside the mock, but that's an
implementation detail.
_______________________
Dr. Nathaniel Pryce
B13media Ltd.
http://www.b13media.com
+44 (0)7712 526 661
----- Original Message -----
From: "Nick Robinson" <nic...@ya...>
To: "Steve Freeman" <st...@m3...>; "JMock Dev"
<jmo...@li...>
Cc: <nmo...@li...>
Sent: Thursday, January 08, 2004 7:38 AM
Subject: [jmock-dev] RE: [Nmock-general] Strict vs Lenient mode for mock
objects
> I personally can see the benefit of the lenient mode, but IMO it should
have
> to be "switched on", and be in switched off mode by default. This is
> similar to my comments about the Strict property. However, if there was
> documentation with NMock, which was accompanied with a few use scenarios
> (showing the use of Strict), such problems I witnessed may not have
> happened.
>
> Thanks,
>
> nick.robinson
> site : www.fromconcept.co.uk
> blog : www.fromconcept.co.uk/weblog.aspx
>
> > -----Original Message-----
> > From: nmo...@li...
> > [mailto:nmo...@li...]On Behalf Of Steve
> > Freeman
> > Sent: 07 January 2004 23:13
> > To: JMock Dev
> > Cc: nmo...@li...
> > Subject: [Nmock-general] Strict vs Lenient mode for mock objects
> >
> >
> > Hello mockistas. We (Steve & Nat) have just spent a semi-productive
> > session designing an API for "lenient mode" mock objects. In lenient
> > mode a mock will return default values from unexpected invocations
> > instead of throwing a test failure.
> >
> > But then we decided that it was a bad idea and deleted all the code.
> >
> > Lenient mode can mask errors and make errors fail slow instead of fast.
> > In fact, Nick Robinson has just complained about this on the nmock list.
> > There is some mechanism underneath to support default values for people
> > who want to pop in their own default stub, but this is not yet exposed
> > properly.
> >
> > What do people think about lenient mode?
> >
> > Cheers,
> > Nat & Steve.
> >
> >
> > -------------------------------------------------------
> > This SF.net email is sponsored by: Perforce Software.
> > Perforce is the Fast Software Configuration Management System offering
> > advanced branching capabilities and atomic changes on 50+ platforms.
> > Free Eval! http://www.perforce.com/perforce/loadprog.html
> > _______________________________________________
> > Nmock-general mailing list
> > Nmo...@li...
> > https://lists.sourceforge.net/lists/listinfo/nmock-general
> >
>
> _______________________________________________
> jmock-dev mailing list
> jmo...@li...
> http://lists.codehaus.org/mailman/listinfo/jmock-dev
|
|
From: Mike B. <mbr...@vi...> - 2004-01-11 17:12:59
|
It makes sense to me. There are many times when I don't really care that a
certain method is called or that it is called more than once. Putting in
expectXXX() calls just clutters my test code and makes it sensitive to
implementation level changes to the real code.
Mike
> -----Original Message-----
> From: nmo...@li...
> [mailto:nmo...@li...]On Behalf Of Nat Pryce
> Sent: Thursday, January 08, 2004 5:56 AM
> To: jmo...@li...; Steve Freeman
> Cc: nmo...@li...
> Subject: Re: [jmock-dev] RE: [Nmock-general] Strict vs Lenient mode for
> mock objects
>
>
> Here's what we are envisaging.
>
> A Mock* has a set of invocation mockers and a default stub that is used to
> provide behaviour for an invocation that doesn't match against any
> invocation mocker.
>
> By default the default stub signals a test failure.
>
> The user will be able to set the default stub to change the default
> behaviour of the mock.
>
> If they change it to a DefaultResultStub then they will get a
> lenient mode.
> They can set up the DefaultResultStub to handle their own classes
> and share
> a single DefaultResultStub among multiple mock objects so that
> they all have
> the same default behaviour.
>
> Code would look like:
>
> public void setUp() {
> DefaultResultStub defaults = new DefaultResultStub();
> defaults.addDefaultResult( Date.class, new Date(-1L) );
> defaults.addDefaultResult( Point.class, new Point(0,0) );
>
> mock = new Mock( MockedInterface.class );
> mock.setDefaultStub( defaults );
> }
>
> What do people think?
> https://lists.sourceforge.net/lists/listinfo/nmock-general
|