|
From: Marcelo de M. S. <cel...@gm...> - 2006-12-29 19:39:38
|
> > 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 > > > |