[seam-dev] the parody of mocks in JSF

Clint Popetz cpopetz at gmail.com
Wed May 6 11:48:06 EDT 2009


We went this route internally for a while with a large client, and it
was a nightmare.  There is no notion of the beginning/end of a
request/session when using a test, and in fact one test execution may
represent many requests.  This represents an impedance mismatch for
injecting into tests.  For example, if you need to inject a
conversational persistence context, you need to set up a fake
conversation context, but then you are not using the same conversation
that your test target request cycles are using.  We have it working
for about 3000 tests, but it's fragile and very dependent on exactly
how Seam 2 works internally.

This would be somewhat more plausible with the way WB handles proxies
for injected beans, but I still recommend extreme caution, based on
experience.

-Clint

On Wed, May 6, 2009 at 10:40 AM, Alaxander Smirnov <asmirnov at exadel.com> wrote:
> I have an idea for the mock testing project. While Shale and all other
> projects use one base class where all mock objects are initialized, the new
> one can utilize Seam/WebBeans 'inverse of control' pattern, where necessary
> mock object should be injected in the same way as components use:
>
> public class FooTest extends .... {
>
> @in
> private FacesContext context;
>
> public void testBar() {
> ...............
> context.get......
> ...............
> }
>
> Therefore all mock initialization code can be moved into separate class,
> that may be used with any test framework ( jUnit 3/4, testng.... ).
>
> Dan Allen wrote:
>>
>>
>> On Tue, May 5, 2009 at 7:22 PM, Alexandr Smirnov <asmirnov at exadel.com
>> <mailto:asmirnov at exadel.com>> wrote:
>>
>>    Ok, do you start that project ? RichFaces uses Shale mocks now, but I
>>    wish to replace that with something more convenient. I can help with
>>    development and contribute existing test classes from richfaces to the
>>    new mocks project.
>>
>>
>> Yes, it is here:  http://anonsvn.jboss.org/repos/seam/modules/trunk/mock/
>>
>> However, give me a day or two while I import what we have from Seam (I
>> need to bring in the mocks from seambay and a couple other places).
>>
>> Exactly, we want to get away from Shale.
>>
>> -Dan
>>
>> --
>> Dan Allen
>> Senior Software Engineer, Red Hat | Author of Seam in Action
>>
>> http://mojavelinux.com
>> http://mojavelinux.com/seaminaction
>> http://in.relation.to/Bloggers/Dan
>>
>> NOTE: While I make a strong effort to keep up with my email on a daily
>> basis, personal or other work matters can sometimes keep me away
>> from my email. If you contact me, but don't hear back for more than a
>> week,
>> it is very likely that I am excessively backlogged or the message was
>> caught in the spam filters.  Please don't hesitate to resend a message if
>> you feel that it did not reach my attention.
>
> _______________________________________________
> seam-dev mailing list
> seam-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/seam-dev
>




More information about the seam-dev mailing list