|
From: Marcelo de M. S. <cel...@gm...> - 2006-12-30 00:31:56
|
Hi Luke, Does that help? > A lot! Thank you very much for taking your time to help me. Marcelo. On 12/29/06, Luke Bayes <lb...@gm...> wrote: > > Hey Marcelo, > > We definitely don't ship test code in our production swf files, but we do > make sure that everything our production code has access to, is available in > our test harness. Regardless of how you physically segment test classes from > production code, the compiler will only include classes that are referenced > one way or another from the main class (MTASC), the main timeline, or > exported symbols (FLA). test cases point at production code, but production > code never references test cases. We have seen projects built with the test > classes alongside the production classes, test packages inside production > packages and like you, have settled on the mirrored test package approach. > Basically, it doesn't matter where the test classes are as long as nothing > from your production compilation references them. > > In environments where we have to use a fla file, we use authoring to > compile it once, then tell MTASC to use the resulting swf file as 'input'. > When you do this, mtasc has access to all those visual assets by their > linkage ids - forms and animations and whatnot. I also (quite handily) > clobbers all ActionScript classes and replaces them with bytecode from it's > compilation. This is a rather simple compiler flag available in MTASC. > > This process tends to work pretty well since we generally modify the code > much more frequently than the visual asset fla. I wouldn't recommend > creating multiple, separate fla files for each different form as this can > make sharing assets and clean compilation much more complicated. > > When you say, "I don't insert any code on the fla file at all. Everything > is coded on external AS2 classes", of course we don't write any ActionScript > in the authoring tool, but we do associate ActionScript 2 classes with > symbols in the fla library using the symbol properties dialog. This > generally seems to work fine - even when post-compiling using MTASC. But the > point is that we wind up with a fla/swf file that is compiled with MMC > (Authoring) - then use MTASC to build the deployed and test harness SWF > files. If we were going to try building something modular that could load > separate content swfs as needed, I suspect we would use a similar process, > using MTASC exclude directives to make the subsequent modular swfs... > > As far as MovieClip instantiation that relies on symbols that aren't > available in the test harness, I would argue that a test swf that doesn't > include everything that exists in the production swf is not thoroughly > testing your production functionality. > > Does that help? > > > Thanks, > > > Luke Bayes > www.asunit.org > > > > On 12/29/06, Marcelo de Moraes Serpa wrote: > > > > This line is usually switched from running our application main function > > > to running our test suite main function > > > > > > I couldn't really understand, Luke. The way I'm doing right now is > > having a test swf and that is all. The way you put it, seems like you mix > > test code with production code, is that right? > > > > Let me explain better how I've set up my unit testing workflow: > > > > I'm using AS2ANT unittest task. So, I compile the TestRunner into a swf > > file and run it before proceeding with the rest of the build. I have two > > identical project trees - one for the production source files and one for > > theses classes' test classes, like this: > > > > * com.cconline.views.IndexView > > * tests.com.cconline.views.IndexViewTest > > > > All the main test classes (TestSuite and TestRunner) are on the test.* > > namespace. > > > > My project consists of various .fla files, one for each of the > > application's views (forms). I find fla's easier for making complex > > design-oriented layouts and sometimes animations. I don't insert any code on > > the fla file at all. Everything is coded on external AS2 classes. > > > > It wasn't also clear on how should I handle MovieClip instantiation on > > the test swf when this MovieClip relies on assets that are not present on > > the test swf's library. > > > > Thanks a lot for the help! > > > > Marcelo. > > > > On 12/29/06, Luke Bayes < lb...@gm...> wrote: > > > > > > 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. > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > Take Surveys. Earn Cash. Influence the Future of IT > > > Join SourceForge.net's Techsay panel and you'll get the chance to > > > share your > > > opinions on IT & business topics through brief surveys - and earn cash > > > > > > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > > > > > _______________________________________________ > > > Asunit-users mailing list > > > Asu...@li... > > > https://lists.sourceforge.net/lists/listinfo/asunit-users > > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > Take Surveys. Earn Cash. Influence the Future of IT > > Join SourceForge.net's Techsay panel and you'll get the chance to share > > your > > opinions on IT & business topics through brief surveys - and earn cash > > > > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > > > _______________________________________________ > > Asunit-users mailing list > > Asu...@li... > > https://lists.sourceforge.net/lists/listinfo/asunit-users > > > > > > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share > your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > _______________________________________________ > Asunit-users mailing list > Asu...@li... > https://lists.sourceforge.net/lists/listinfo/asunit-users > > > |