|
From: Luke B. <lb...@gm...> - 2006-12-29 19:19:06
|
Hey Marcelo, There are a couple of issues you're talking about here, I'm going to restate them a little differently, please let me know if this is inaccurate. 1) Should I ever write a unit test for a visual entity? Yes. There are definitely times when views have code. Even using MVC, the view is responsible for some work and unit testing can verify that this work is being done as expected. 2) How do I structure an application for unit testing? Ali and I spent a considerable amount of time thinking about this problem, and after quite a bit of trial and error, we realized that one of the most important aspects to testing is that the environment your test harness operates in should be as nearly identical to your production environment as possible. This includes library assets, frameworks, etc... For example, Macromedia's components manipulate some core object prototypes, add functions to _global and place assets on _root in a very high level which affects our ability to use _root.getNextHighestDepth(). IF we are using components in our application, but fail to load that library into our test swf, we will see behaviors in production that are very different from those that we find in our tests. We generally try to avoid using a fla file if at all possible, but if we are forced to use a .fla file for a project, the most important thing that we do, is avoid doing any real work on the main timeline. If we have some animation or some frame-based work that needs done, we put it into a MovieClip. The main timeline of our .fla files generally has one line of ActionScript. This line is usually switched from running our application main function to running our test suite main function. This has the added benefit of allowing us to point MTASC at either of these main functions and simply swallow the MMC-compiled swf file. // SomeApplication.main(); SomeApplicationRunner.main(); I hope that helps. Luke Bayes www.asunit.org On 12/29/06, Marcelo de Moraes Serpa wrote: > > Hi Luke, thanks for the reply :) > > It is still not clear to me the role of MovieClip classes on asunit unit > tests. From what I've been reading about Unit Testing so far, I can > understand that visual entities should not be unit tested directly. Instead, > the business classes that are used by it should be tested and I don't think > business classes should inherit MovieClip (am I misunderstanding something > here?). > > But let's say I really want to instantiate a MovieClip class on my unit > test. The XUL UI feature you described is for creating mock objects for > MovieClip classes, right? I'm asking this becouse it would be too much of a > stress to try to instantiate a regular "non-serializable" MovieClip class as > it depends on assets that are not present on the test swf library (and > should not be present, I'm almost sure!). > > Cheers, > > Marcelo. > > |