tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/3202-writing-unit-tests-for-flex-4-appproblems-testing-with-skinsRobotlegs: Discussion 2013-08-17T10:52:50Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/277474982013-07-12T16:53:21Z2013-07-12T16:55:33ZWriting unit tests for Flex 4 app..problems testing with skins<div><p>I'm embarking on my first major foray into writing unit tests in
tandem with refactoring legacy code. The examples in AS Developer's
Guide to Robotlegs have provided adequate guidance thus far.
However, I am experiencing the following issues, both related to
the corresponding skins:</p>
<ol>
<li>The tests for mediators eventually pass, but I get warnings
indicating that skins cannot be found.<br></li>
<li>I have a skin which contains a click event that is listened to
by a mediator 2 levels up through
eventMap.maplistener(view.parent.label...). The problem is that I
get a null reference to this label when I run the test. I have
attempted to dispatch an event from the skin and addContextListener
to the mediator to listen for this event, but this does not seem to
work.</li>
</ol>
<p>Any suggestions for either issue?</p></div>danatroymediatag:robotlegs.tenderapp.com,2009-10-18:Comment/277474982013-07-21T15:07:41Z2013-07-21T15:07:41ZWriting unit tests for Flex 4 app..problems testing with skins<div><p>Hello. So you're first issue (1) doesn't seem to really be a
problem, just a compiler warning.</p>
<p>The second issue is because of that
<code>view.parent.label</code> reference. This is very bad, and you
should really try and rearrange your code so that the mediator is
not digging around through the Display List like that. Your
mediator is currently interacting with things outside of the scope
of your view (it is digging up via <code>parent</code>), which is
very fragile.</p></div>Shaun Smith