Kevin | 1 Oct 02:55 2010
Picon

Matching null array argument

I've got a tough one, searched and searched for the answer.

My interface has a method named myMethod(String[]);

I'm trying to mock up the interface, and during the unit test, the code calls 
myMethod(null);  

I can't write an expectation that will successfully match this.  I either run 
into syntax errors in my IDE, or it fails to match at runtime.  

Any help is appreciated.  Thanks.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

steve.freeman | 4 Oct 08:21 2010
Picon

Re: Matching null array argument

Oops we didn't respond to this. I'm offline now but I think one option for a simple match would be to pass in a
null, cast to a string array. For a more complex match, you need a null matcher cast to a Matcher<String[]>.
I usually package these up in helper methods to reduce the noise.

Sorry about this but we hit the buffers of Java generics.  

Steve Freeman
steve.Freeman@...

On 1 Oct 2010, at 01:55, Kevin <kmbulebu2@...> wrote:

> I've got a tough one, searched and searched for the answer.
> 
> My interface has a method named myMethod(String[]);
> 
> I'm trying to mock up the interface, and during the unit test, the code calls 
> myMethod(null);  
> 
> I can't write an expectation that will successfully match this.  I either run 
> into syntax errors in my IDE, or it fails to match at runtime.  
> 
> Any help is appreciated.  Thanks.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
> 
>    http://xircles.codehaus.org/manage_email
> 
> 
(Continue reading)

David Carlton | 22 Oct 02:51 2010

using <at> Mock

The jMock documentation at <http://www.jmock.org/auto.html> says that I can use <at> Mock to create mock objects, but that annotation isn't resolving for me; am I doing something stupid, or is the documentation wrong for the version I'm using?  (I'm using 2.5.1.)


My apologies if this is a FAQ - the e-mail archive search ignores the <at> character, so searching for <at> Mock turns up a lot of false positives.

(Incidentally, I'm very pleased that I've finally started using jMock - it's made the last week and a half of programming extremely pleasant.)

--
David Carlton
carlton <at> bactrian.org
Julian Hall | 22 Oct 09:49 2010
Picon

Re: using <at> Mock

On 22/10/2010 01:51, David Carlton wrote:
> The jMock documentation at <http://www.jmock.org/auto.html> says that 
> I can use  <at> Mock to create mock objects, but that annotation isn't 
> resolving for me; am I doing something stupid, or is the documentation 
> wrong for the version I'm using?  (I'm using 2.5.1.)
>
> My apologies if this is a FAQ - the e-mail archive search ignores the 
>  <at>  character, so searching for  <at> Mock turns up a lot of false positives.
>
> (Incidentally, I'm very pleased that I've finally started using jMock 
> - it's made the last week and a half of programming extremely pleasant.)
>
Looking at the javadocs, this appears to be a new feature in the 
unstable 2.6.0 release candidate.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Steve Freeman | 22 Oct 10:28 2010
Picon

Re: using <at> Mock

Also, have you remembered to use the  <at> RunWith(JMock) annotation?

glad you liked it.

S

On 22 Oct 2010, at 08:49, Julian Hall wrote:
> On 22/10/2010 01:51, David Carlton wrote:
>> The jMock documentation at <http://www.jmock.org/auto.html> says that I can use  <at> Mock to create mock
objects, but that annotation isn't resolving for me; am I doing something stupid, or is the documentation
wrong for the version I'm using?  (I'm using 2.5.1.)
>> 
>> My apologies if this is a FAQ - the e-mail archive search ignores the  <at>  character, so searching for  <at> Mock
turns up a lot of false positives.
>> 
>> (Incidentally, I'm very pleased that I've finally started using jMock - it's made the last week and a half
of programming extremely pleasant.)
>> 
> Looking at the javadocs, this appears to be a new feature in the unstable 2.6.0 release candidate.

Steve Freeman

Winner of the Agile Alliance Gordon Pask award 2006
Book: http://www.growing-object-oriented-software.com

+44 (0) 797 179 4105
M3P Limited.  http://www.m3p.co.uk
Registered office. 2 Church Street, Burnham, Bucks, SL1 7HZ. 
Company registered in England & Wales. Number 03689627

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

David Carlton | 22 Oct 18:12 2010

Re: using <at> Mock

On Fri, Oct 22, 2010 at 12:49 AM, Julian Hall <jules-XaFKWIIMX1WZkjO+N0TKoCp2UmYkHbXO@public.gmane.org> wrote:

On 22/10/2010 01:51, David Carlton wrote:
The jMock documentation at <http://www.jmock.org/auto.html> says that I can use <at> Mock to create mock objects, but that annotation isn't resolving for me; am I doing something stupid, or is the documentation wrong for the version I'm using?  (I'm using 2.5.1.)

My apologies if this is a FAQ - the e-mail archive search ignores the <at> character, so searching for <at> Mock turns up a lot of false positives.

(Incidentally, I'm very pleased that I've finally started using jMock - it's made the last week and a half of programming extremely pleasant.)

Looking at the javadocs, this appears to be a new feature in the unstable 2.6.0 release candidate.

Ah, cool, thanks. 


--
David Carlton
carlton-1jVtk91VtHFg9hUCZPvPmw@public.gmane.org
David Carlton | 22 Oct 18:12 2010

Re: using <at> Mock

Yes, thanks.

On Fri, Oct 22, 2010 at 1:28 AM, Steve Freeman <steve-/6t1Ty3A97Vaa/9Udqfwiw@public.gmane.org> wrote:
Also, have you remembered to use the <at> RunWith(JMock) annotation?

glad you liked it.

S

On 22 Oct 2010, at 08:49, Julian Hall wrote:
> On 22/10/2010 01:51, David Carlton wrote:
>> The jMock documentation at <http://www.jmock.org/auto.html> says that I can use <at> Mock to create mock objects, but that annotation isn't resolving for me; am I doing something stupid, or is the documentation wrong for the version I'm using?  (I'm using 2.5.1.)
>>
>> My apologies if this is a FAQ - the e-mail archive search ignores the <at> character, so searching for <at> Mock turns up a lot of false positives.
>>
>> (Incidentally, I'm very pleased that I've finally started using jMock - it's made the last week and a half of programming extremely pleasant.)
>>
> Looking at the javadocs, this appears to be a new feature in the unstable 2.6.0 release candidate.

Steve Freeman

Winner of the Agile Alliance Gordon Pask award 2006
Book: http://www.growing-object-oriented-software.com

+44 (0) 797 179 4105
M3P Limited.  http://www.m3p.co.uk
Registered office. 2 Church Street, Burnham, Bucks, SL1 7HZ.
Company registered in England & Wales. Number 03689627




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email





--
David Carlton
carlton-1jVtk91VtHFg9hUCZPvPmw@public.gmane.org

Gmane