Hi Peter,
Thanks for that. That is just normal EasyMock testing isn't it? I don't see 
where tapestry comes into that at all? You are creating the instances of all 
the classes and you are creating the instance of the class under test aren't 
you? Where is the PageTester and Tapestry IoC and all that (or have you missed 
some code, or am I missing something?)



What I meant was this:- In the src/main/java tree I have MyAppModule which has 
some services like

Binder.bind(MyService.class, MyExpensiveExternalImpl.class)

But in my src/test/java tree I have 

@SubModule( { MyAppModule.class })
MyAppTestModule

public static MyService buildMyService () {
                return EasyMock.createMock(MyService.class);    
}


(In the actual App the MyService Impl will be provided by Spring but that is by 
the by)

So that when I use PageTester in my tests I can go

MyService myMockService = pageTester.getRegistry().getService(MyService.class);

EasyMock.expect(myMockService.expensiveExternalMethodCallToCreditCardGatewayIdontReallyWantToTest(myCardNumber)).andReturn(authCode);


But the problem is...the registry returns a Proxy that contains a 
JustInTimeObjectCreator so EasyMock won't have no truck with my mock service. 
Boo.

Cheers

Russell





-----Original Message-----
From: Peter Stavrinides [mailto:[EMAIL PROTECTED] 
Sent: 17 September 2008 14:08
To: Tapestry users
Subject: Re: T5: testing using PageTester and EasyMock

Sorry about that hit the send by accident, here is the rest of it:
        @BeforeClass
        public static void setup() {

                // tapestry interfaces
                _mockAsm = createMock(ApplicationStateManager.class);
                _mockContext = createMock(Context.class);
                _mockResponse = createMock(Response.class);
                _mockRequest = createMock(Request.class);

                // an interface of my own
                _mockSiteError = createMock(ISiteError.class);

                _transport = new SMTPTransport("mailrelay",25);
        }

        /**
         * Test the properties for the service are set correctly and that the
         * service can be constructed
         */
        @Test
        public final void testConstruction() {
                
expect(_mockContext.getInitParameter("DevelopmentMode")).andReturn(
                                "false");
                expect(_mockContext.getInitParameter("MailServer")).andReturn(
                                "mailrelay");
                replay(_mockContext);

                // now see if we can construct an instance of the class under 
test
                _mockSiteErrorImpl = new SiteErrorImpl(_mockAsm, _mockContext,
                                _mockResponse, _mockRequest);
                // run the verify
                verify(_mockContext);
        }




----- Original Message -----
From: "Russell Brown" <[EMAIL PROTECTED]>
To: "Tapestry users" <users@tapestry.apache.org>
Sent: Wednesday, 17 September, 2008 2:00:12 PM GMT +02:00 Athens, Beirut, 
Bucharest, Istanbul
Subject: RE: T5: testing using PageTester and EasyMock

Hi Peter,
How have you done this? When I try to use Tapestry to "Build" my EasyMock 
services the resultant proxies are rejected by EasyMock as not being EasyMock 
proxies...

Cheers

Russell

-----Original Message-----
From: Peter Stavrinides [mailto:[EMAIL PROTECTED] 
Sent: 17 September 2008 11:47
To: Tapestry users
Subject: Re: T5: testing using PageTester and EasyMock

Hi all,

I haven't got around to using PageTester yet, but I started using Easymock for 
my IoC services recently... Its quite amazing how you can create a full blown 
IoC service with all dependencies satisfied so easily, it just works since 
service proxies are all interfaces in Tapestry.



----- Original Message -----
From: "Angelo Chen" <[EMAIL PROTECTED]>
To: users@tapestry.apache.org
Sent: Wednesday, 17 September, 2008 1:16:57 PM GMT +02:00 Athens, Beirut, 
Bucharest, Istanbul
Subject: Re: T5: testing using PageTester and EasyMock


Hi,

This will be a very interesting topic, I'd like to see how TDD can be used
in the development of T5 pages, my experience with T5 page tester isn't so
successful, now I try to do everything in the services as it is a easy place
to test.

angelo


akochnev wrote:
> 
> 
> Let's keep this discussion rolling, we certainly need a little more info
> on
> testing in T5.
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/T5%3A-testing-using-PageTester-and-EasyMock-tp19496126p19529056.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


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


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

Reply via email to