You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by Daniel Tiefenauer <Da...@crealogix.com> on 2014/04/30 13:21:27 UTC

FlexUnit 4.2 UIImpersonator

Hi there
I'm trying to perform UI-Tests for a Mobile Application created with Flex 4.12.0. I'm following the tutorial under http://flex.apache.org/flexunit/tutorial/flexunit/Unit-14.html. However, I can't get this to work. When using UIImpersonator to add an UI component (even a Spark Button), the "creationComplete"-Event is never thrown. Hence I can't perform unit tests on the UI Components because the nested sub-elements are not present.

Here's what I did:
                    loginView = new LoginView();
                    Async.proceedOnEvent(this, loginView, StateChangeEvent.CURRENT_STATE_CHANGE);
                    UIImpersonator.addChild(loginView);

As said, I have tried this with a spark button, but it does not work. The tutorial mentioned above uses MX-Components. Can Spark components be tested at all?

Regards
Daniel

AW: FlexUnit 4.2 UIImpersonator

Posted by Daniel Tiefenauer <Da...@crealogix.com>.
Hey Mark
Of course. Here you go (many thanks in advance):

	public class LoginViewTest
	{		
		/*============================================================================*/
		/* Private Properties                                                         */
		/*============================================================================*/
		private var loginView:LoginView;
		
		/*============================================================================*/
		/* Test Setup and Teardown                                                    */
		/*============================================================================*/
		[Before(async,ui)]
		public function setUp():void
		{
			loginView = new LoginView();
			Async.proceedOnEvent(this, loginView, FlexEvent.CREATION_COMPLETE, 1000);
			UIImpersonator.addChild(loginView);
		}
		
		[After(async,ui)]
		public function tearDown():void
		{
			UIImpersonator.removeAllChildren();
			loginView = null;
		}
		
		[BeforeClass]
		public static function setUpBeforeClass():void
		{
			if (!translationProxy)
				translationProxy = new TranslationProxy();
		}
		
		[AfterClass]
		public static function tearDownAfterClass():void
		{
		}
		
		/*============================================================================*/
		/* Tests                                                                      */
		/*============================================================================*/        
		[Test(async, ui)]
		public function shouldAssert():void{
			assertEquals(true, true);
		}


-----Ursprüngliche Nachricht-----
Von: Mark Line [mailto:markline@gmail.com] 
Gesendet: Mittwoch, 30. April 2014 13:34
An: users@flex.apache.org
Betreff: RE: FlexUnit 4.2 UIImpersonator

I've not done any testing for a mobile project but can confirm its working correctly with spark components.

Do you have a whole class we can have a look at? (PS you can't use attachments here)

Here is a basic example:

    public class MyTest
    {
        private var _myForm:MyForm;

		[Before(async,ui)]
		public function setUp():void
		{
			_ myForm = new MyForm ();
			Async.proceedOnEvent(this, _ myForm,
FlexEvent.CREATION_COMPLETE, 50000);
			UIImpersonator.addChild(_myForm);
		}
		[After(async,ui)]
		public function tearDown():void
		{
			UIImpersonator.removeChild(_myForm);
			_ myForm = null;
		}


		[Test(async,ui)]
       		 public function checkSomethingTest():void
        		{
			assertEquals(true,true)
        		}
}

-----Original Message-----
From: Daniel Tiefenauer [mailto:Daniel.Tiefenauer@crealogix.com]
Sent: 30 April 2014 12:21
To: users@flex.apache.org
Subject: FlexUnit 4.2 UIImpersonator

Hi there
I'm trying to perform UI-Tests for a Mobile Application created with Flex 4.12.0. I'm following the tutorial under http://flex.apache.org/flexunit/tutorial/flexunit/Unit-14.html. However, I can't get this to work. When using UIImpersonator to add an UI component (even a Spark Button), the "creationComplete"-Event is never thrown. Hence I can't perform unit tests on the UI Components because the nested sub-elements are not present.

Here's what I did:
                    loginView = new LoginView();
                    Async.proceedOnEvent(this, loginView, StateChangeEvent.CURRENT_STATE_CHANGE);
                    UIImpersonator.addChild(loginView);

As said, I have tried this with a spark button, but it does not work. The tutorial mentioned above uses MX-Components. Can Spark components be tested at all?

Regards
Daniel


RE: FlexUnit 4.2 UIImpersonator

Posted by Mark Line <ma...@gmail.com>.
I've not done any testing for a mobile project but can confirm its working
correctly with spark components.

Do you have a whole class we can have a look at? (PS you can't use
attachments here)

Here is a basic example:

    public class MyTest
    {
        private var _myForm:MyForm;

		[Before(async,ui)]
		public function setUp():void
		{
			_ myForm = new MyForm ();
			Async.proceedOnEvent(this, _ myForm,
FlexEvent.CREATION_COMPLETE, 50000);
			UIImpersonator.addChild(_myForm);
		}
		[After(async,ui)]
		public function tearDown():void
		{
			UIImpersonator.removeChild(_myForm);
			_ myForm = null;
		}


		[Test(async,ui)]
       		 public function checkSomethingTest():void
        		{
			assertEquals(true,true)
        		}
}

-----Original Message-----
From: Daniel Tiefenauer [mailto:Daniel.Tiefenauer@crealogix.com] 
Sent: 30 April 2014 12:21
To: users@flex.apache.org
Subject: FlexUnit 4.2 UIImpersonator

Hi there
I'm trying to perform UI-Tests for a Mobile Application created with Flex
4.12.0. I'm following the tutorial under
http://flex.apache.org/flexunit/tutorial/flexunit/Unit-14.html. However, I
can't get this to work. When using UIImpersonator to add an UI component
(even a Spark Button), the "creationComplete"-Event is never thrown. Hence I
can't perform unit tests on the UI Components because the nested
sub-elements are not present.

Here's what I did:
                    loginView = new LoginView();
                    Async.proceedOnEvent(this, loginView,
StateChangeEvent.CURRENT_STATE_CHANGE);
                    UIImpersonator.addChild(loginView);

As said, I have tried this with a spark button, but it does not work. The
tutorial mentioned above uses MX-Components. Can Spark components be tested
at all?

Regards
Daniel