Quantcast
Channel: Adobe Community : Popular Discussions - FlexUnit
Viewing all articles
Browse latest Browse all 25673

UIImpersonator tests work in FlashBuilder, but not when run from Ant

$
0
0

I'm in the process of converting a Flex 3 project to use FlexUnit4 tests.

Everything compiles in Flashbuilder 4.5 and runs nicely. I've converted all the tests

to use flexunit 4, which highlighted a few issues, but nothing too major, and all the

tests now pass when run in Flashbuilder.

 

So... now, I'm trying to convert the CI build to use the 4.5 SDK and flexunit4. So far,

so good. Everything runs and I get a nicely formatted JUnit report. Unfortunately, though,

any test that uses the UIImpersonator fails with an async method timeout, suggesting that

the CreationComplete event hasn't fired.

 

Here's a typical example of one of my UI test cases:

 

          [Test(async, ui)]          public function testAvailableProductsSetupAdminForSell() : void {                              var view:OrderBasketView = new OrderBasketView();                              var user:CfxUser = new CfxUser();               user.admin = true;               ModelLocator.instance.userDetails = user;                              view.buyOrSell = OrderType.SELL;                              helper.createComponentAndAddListener(view, this, availableProductSetupAdminForSellCreationComplete);                         }                    private function availableProductSetupAdminForSellCreationComplete(event:Event, view:OrderBasketView) : void {               Assert.assertTrue(view.availableProductTypes.contains(ProductType.PRODUCT_1));               Assert.assertTrue(view.availableProductTypes.contains(ProductType.PRODUCT_2));               Assert.assertTrue(view.availableProductTypes.contains(ProductType.PRODUCT_3));                         }

 

and helper.createComponentAndAddListener looks like this:

        public function createComponentAndAddListener(view:UIComponent, testCase:Object, creationComplete:Function) : void {               _view = view;               _view.addEventListener(FlexEvent.CREATION_COMPLETE, Async.asyncHandler(testCase, creationComplete, 4000, _view));               UIImpersonator.addChild(_view);        }

 

 

If I use FlexGlobals.topLevelApplication.parent.addChild(_view) in place of UIImpersonator.addChild(_view), all the tests pass.

 

I was wondering if it's a function of the fact that my helper class has no metadata that indicates it's a ui test, but that wouldn't explain why it works in FlashBuilder and not when run with ant.

 

I also wondered if it was a function of running with headless server set to true, but when I changed it to false the same thing happened.

 

My environment is:

ubuntu 11.04

ant 1.7.1

Sun jdk 1.6.0_26

Flex SDK 4.5.1.21328

FlexUnit 4.1.0-8-4.1.0.16076

 

I'm using the auto-generated TestRunner.mxml

 

Any thoughts, anyone? Now that I can get it to work by adding the UI components to the topLevelApplication, at least I can make progress, but I'd like to get to the bottom of the problem, because that shouldn't be necessary.

 

Thanks in advance,

 

-Chrisl


Viewing all articles
Browse latest Browse all 25673

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>