atom feed8 messages in org.codehaus.jmock.userRe: [jmock-user] Re: Aggregating Expe...
FromSent OnAttachments
IncognitoNov 19, 2007 11:33 am 
Steve FreemanNov 19, 2007 3:05 pm 
IncognitoNov 19, 2007 4:21 pm 
Steve FreemanNov 19, 2007 11:31 pm 
Dale KingNov 20, 2007 7:32 am 
Steve FreemanNov 20, 2007 2:51 pm 
Nat PryceNov 20, 2007 3:12 pm 
quak...@aol.comNov 21, 2007 1:59 pm 
Subject:Re: [jmock-user] Re: Aggregating Expectation instances
From:quak...@aol.com (quak@aol.com)
Date:Nov 21, 2007 1:59:04 pm
List:org.codehaus.jmock.user

yep, that works perfectly, thanks. I didn't know one could invoke checking
multiple times.

{

-----Original Message----- From: Dale King <dale@gmail.com> To: us@jmock.codehaus.org Sent: Tue, 20 Nov 2007 10:32 am Subject: Re: [jmock-user] Re: Aggregating Expectation instances

How about this:

@Before

public void setUp() {

? mockery.checking( new Expectations() ? {

? ? ?expectation1

? ? ?expectation2

? ? ?expectation3 ? } ); }

@Test

public void testA() {

? mockery.checking( new Expectations()

? {

? ?? expectation4 ? } );

}

@Test public void testB() {

? mockery.checking( new Expectations()

? {

? ?? expectation5 ? } );

}

And I do not agree with Steve that this necessarily indicates some design
problem or missing object. This is a very common pattern to have different test
cases that have common expectations.

On Nov 19, 2007 7:21 PM, Incognito <quak@aol.com> wrote:

Steve Freeman <steve@...> writes:

I don't understand. Why do you want to do this?

S.

On 19 Nov 2007, at 19:33, Incognito wrote:

Is there any way to accomplish the following pseudo code?

Expectations expectations1 = new Expectations() {{ ?one( ... ) ? ?... }});

Expectations expectations2 = new Expectations() {{ ?allowing( ... ) ? ?... ?andAllOf( expectations1 ); }});

Steve Freeman Winner of the Agile Alliance Gordon Pask award 2006

http://www.m3p.co.uk

M3P Limited. 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

I have a test class with around 20 tests in it. Each tests sets up 3 or 4 expectations but they all use two common expectations which I have (now)

duplicated for each method:

@Test public void testA() { ? mockery.checking( ... ) ? ? ?expectation1 ? ? ?expectation2 ? ? ?expectation3 ? ? ?expectation4 }

@Test public void testB() {

? mockery.checking( ... ) ? ? ?expectation1 ? ? ?expectation2 ? ? ?expectation3 ? ? ?expectation5 <= varies here }

Id rather be able to something like the following:

private Expectations getCommonExpectations() {

? return ... }

@Test public void testA() { ? mockery.checking( ... ) ? ? ?getCommonExpectations() ? ? ?expectation4 }

@Test public void testB() { ? mockery.checking( ... )

? ? ?getCommonExpectations() ? ? ?expectation5 <= varies here

}

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

? ?http://xircles.codehaus.org/manage_email

-- Dale King

________________________________________________________________________ Email and AIM finally together. You've gotta check out free AOL Mail! -
http://mail.aol.com