Mock Spark component

33 views
Skip to first unread message

NagRock

unread,
Jul 11, 2012, 6:51:42 AM7/11/12
to mock...@googlegroups.com
Hi, when I want to prepare mock for spark component it takes really long time... And when i turn on coverage plugin... tests takes GB of ram and never ends...

Hob Spillane

unread,
Jul 11, 2012, 11:53:42 AM7/11/12
to mock...@googlegroups.com

Mocking of view components takes a very long time. Your best option is to create an interface for your view so that you can mock the interface instead.

Drew Bourne

unread,
Jul 11, 2012, 5:47:05 PM7/11/12
to mock...@googlegroups.com
Perfect answer Hob. 

Anything deriving from UIComponent will take a long time to generate the proxy as it has hundreds of methods and accessors. And this happens for each separate UIComponent-subclass that you give to Mockolate. 

I am considering a feature to allow specifying which methods should be proxied, however even if this feature was available now I would strongly suggest using interfaces instead. Consider using IUIComponent or IVisualElement, or something custom depending on your requirements. 

cheers, 
Drew

NagRock

unread,
Jul 12, 2012, 5:08:22 AM7/12/12
to mock...@googlegroups.com
Thanks, sounds great. Gona check it :)

NagRock

unread,
Jul 12, 2012, 7:00:28 AM7/12/12
to mock...@googlegroups.com
Hi, but when I want to mock for example spark DataGrid i have only: IFocusManagerComponent, IIMESupport for that component.

So I don't have interface for it.

I wanto to check if dataProvider setter was called.

Hob Spillane

unread,
Jul 12, 2012, 12:22:36 PM7/12/12
to mock...@googlegroups.com

In those cases, what I'll typically do is create a new interface that defines only the methods I need to interact with, then implement that method myself on a sub-class of the view I'm trying to mock.

Stray

unread,
Jul 12, 2012, 7:50:30 AM7/12/12
to mock...@googlegroups.com
+1 for this method.

NagRock

unread,
Jul 12, 2012, 7:55:58 AM7/12/12
to mock...@googlegroups.com
Thanks again. You really helped me :)

Theo

unread,
Jul 23, 2012, 5:20:00 AM7/23/12
to mock...@googlegroups.com
When testing mediators I need to mock their views. What I often do is create a partial mock, it doesn't take long and will still dispatch events (something that I often need my views to do), however you can still mock all the calls you want and set exceptions etc. 

Theo.
Reply all
Reply to author
Forward
0 new messages