You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Robert Zeigler <ro...@scazdl.org> on 2009/03/02 19:25:03 UTC

Re: Providing service mocks for integration tests

Are you using PageTester or Selenium?

Thinking about this a bit more, I've taken this approach with  
PageTester, where it's easy: just specify the appropriate module (or  
add it) as necessary.
I've also taken this approach with selenium testing, but typically  
setup a "testing" application (similar to, eg, app1, app2, etc. in  
tapestry-core/src/test).

Are you trying to integration test the application via selenium (ie,  
extending AbstractionIntegrationTestSuite), but also trying to  
override select services with "testing" implementations?
In that case, what I would probably do is to forget the @SubModule bit  
(but still use Alias/AliasOverrides), and then you can add your test  
module via the tapestry.modules system property, as in:
tapestry 
.modules 
= 
com 
.example 
.app 
.testing 
.services.TestModule,com.example.app.testing.services.TestModule2 and  
so forth.

Cheers,

Robert

On Feb 26, 2009, at 2/264:41 PM , Hugo Palma wrote:

> I was just going to try out the alias/alias override but stopped  
> before i
> got to that.
> How do i tell my application to use a different application module  
> when
> testing ?
>
> On Tue, Feb 24, 2009 at 4:04 AM, Robert Zeigler <ro...@scazdl.org>  
> wrote:
>
>> One thing I've done is to create a test module that @SubModule's the
>> application module, and then uses alias/alias overrides to spot- 
>> override
>> services from the sub-module (the application module) with test- 
>> specific
>> services.  Works pretty well.
>>
>> Robert
>>
>>
>> On Feb 23, 2009, at 2/236:06 PM , Hugo Palma wrote:
>>
>> I'm implementing my user interface tests using selenium and the  
>> provided
>>> AbstractIntegrationTestSuite class. Everything is working fine.
>>>
>>> Still, i'd like to replace my DAO services implementation with  
>>> some mock
>>> ones when i run the tests. The problem is that the services are  
>>> declared
>>> in
>>> the application module so how do i override those declarations for  
>>> testing
>>> purposes ?
>>> One workaround i found was to pass a VM parameter when i run the  
>>> test goal
>>> and then in the bind method implementation i check for the  
>>> parameter and
>>> declare either the prodution implementation or the mock one.  
>>> Although this
>>> works it forces me to implement the mock objects in the main  
>>> sources and
>>> not
>>> on the test sources where they should be.
>>>
>>> I was wondering if anyone had a better way to do this.
>>> Thanks.
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org