Flex Unit 4 - Hello World

I want to use Flex Flex Suite.

I have no experience testing modules.

I uploaded the Turnkey project , but I was a bit overloaded.

I just want to start by creating a simple hello world unit test.

if I have a class called MyClasswith two methods square()and cube().

and I want to create a unit test as follows:

public class MyTest 
{
    public function testMyClass():void
    {
        var myClass:MyClass = new MyClass();

        assert(myClass.square(7) == 49);
        assert(myClass.cube(7) == 343);
        assert(myClass.square(5) == 50); // should fail
    }
}

How can I make this work?

+3
source share
2 answers

Add a new application to your Flex project - name it the suffix "UnitTest.mxml". Add a link to TestRunnerBase, and on createComplete run TestRunnerBase. This should start:

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:flexunit="flexunit.flexui.*" creationComplete="init();"><mx:Script>
  <![CDATA[

        import flexunit.framework.TestSuite;
  import FlexUnit.*;

  private function init():void{
   test.test = initSuite();
   test.startTest();
  }

  private function initSuite():TestSuite{
   var suite:TestSuite = new TestSuite();
   suite.addTestSuite(testMyClass);
   return suite;
  }
  ]]>
 </mx:Script>
 <flexunit:TestRunnerBase id="test" width="100%" height="100%" />
</mx:Application>
+1

, , ? - , -, , , .

ASUnit. Flex - , - ASUnit Flex proj - , , ASUnit.

, - , , adamcodes.

+1

Source: https://habr.com/ru/post/1770136/


All Articles