|
From: Luke B. <lb...@gm...> - 2006-11-28 17:44:21
|
> How do I control the UI in the AsUnitTestRunner? It is showing the output > of > my tests just fine; unfortunately it takes the whole screen so I can=B9t = see > the app itself! Hey David, Yet another really good question. Please keep them coming! Basically, you don't want to run your entire application while running your Unit Test harness. The way we have usually managed this, is to create a mai= n application file and use a separate main test runner. Then we switch betwee= n the two when we're building to deployment vs development targets. The major drawback to this approach when you're working with a FLA file, is that it means you can't build a streaming / frame-based file. All of your functionality needs to be placed inside of Symbols, and attached at initialization. When you run the test harness, you shouldn't actually see anything, the test suite should just run from beginning to end without displaying any part of your application. Once you have the application structured in this way, simply create a new Test Case, and within the setUp() override, call attachMovie. We have implemented this method on TestCase (which is *not* a MovieClip) so that yo= u won't have to manage unique instance names or depths. You *can* if you want to, but we recommend that you don't because the Flash Players 6, 7 and 8 don't really handle synchronous creation and destruction of MovieClips very well... The revised method signature looks like this: attachMovie(linkageId:String, initObj:Object =3D null):MovieClip If you use this method, AsUnit will attach a MovieClip instance over the UI= . You should also take the return value and put it into a member variable so that you can later call removeMovieClip(instance:MovieClip) in the override of tearDown(). Once you have this process sorted out, you will be able to easily test smal= l components of your application. When the TestCase is typically executed, fo= r each method found that matches "test*", it will call, setUp(), [the method]= , then tearDown(). After doing this for each method, it will call "cleanUp", just in case you have some more work to do... Now - to your question, how do I *look* at my stuff while I'm working on tests? In your main test runner, where you call start(AllTests), you can instead call start(MyTestCase:Class, methodName:String). This will tell AsUnit to load the referenced TestCase, call setUp(), and then only call the testMethod whose name was identified. Teardown will not be called. This allows to you build up your test cases for visual elements one method at a time, all the while visually verifying that your entities d= o what you expect. As you build up a TestCase, don't forget to run the whole suite before you check code into version control. That can be done by simpl= y changing the start method back to start(AllTests). Please let me know if this helps, and if you have any more questions. We're most interested in helping people that have never written tests before, and trying to make their first experiences as painless as possible. Thanks, Luke Bayes www.asunit.org |