2 Replies Latest reply on Feb 21, 2011 6:50 AM by rrsIPOV2

    Running Old TestSuite in new Framework

    rrsIPOV2 Level 1

      Hi.

       

      I have a TestSuite (largish) that was written for FlexUnit 0.9  I would like to run it "as is" - with minimal or no changes execpt for the encompassing MXML file using the latest FlexUnit. Is this possible?  Looking through the documents it seems like it should be doable, but I can't seem to find a good example, and all my attempts have failed with a "no runable methods" error.  The test suite in question uses one master test suite subclass with multiple calls to addTestSuite() in its constructor.  If I need to alter this main class I would be ok, but I don't fancy having to rewrite all the TestSuites it links to.

       

      Example script from MXML file (doesn't work):

       

      var fuCore:FlexUnitCore = new FlexUnitCore();
      fuCore.addListener( new CIListener() );
      fuCore.addListener( new UIListener(uiListener) );
      
      fuCore.run( MyTestSuite );
      

       

      I have tried using the SuiteMethod class to wrap this, but this isn't working for me either.

        • 1. Re: Running Old TestSuite in new Framework
          mlabriola Level 4

           

          >I have a TestSuite (largish) that was written for FlexUnit 0.9  I would like to run it "as is" - with minimal or no changes execpt for the encompassing MXML file >using the latest FlexUnit. Is this possible?

           

          So, first, yep, totally possible. In fact, we actually run the original FlexUnit .9 tests as part of our test suite for the project. FlexUnit 4 just looks through each test it finds and attempts to identify the right way to run the class. FlexUnit .9 is one of those ways.

           

          >Looking through the documents it seems like it should be doable, but I can't seem to find a good example, and all my attempts have failed with a "no runable >methods" error.

           

          So, there isn't anything special that you need to do, just pass the original testsuite into the run() method

           

          >>The test suite in question uses one master test suite subclass with multiple calls to addTestSuite() in its constructor.  If I need to alter this main class I >>would be ok, but I don't fancy having to rewrite all the TestSuites it links to.

           

          No, that should be fine with no reason to modify it at all. However, looking through our test cases, I see that we test a FlexUnit .9 test case and a statis Suite() method but I don't see a test case that calls addTestSuite() in the constructor, so I will check that out tomorrow. If there is a problem there, it will be trivial to give you a patched version until we push the fix into the next release .

           

          Your code for running the tests looks proper:

           

          I am pasting in the FlexUnit.9 TestSuite we test with so perhaps you can see the difference. I will write a test against adding these in the constructor tomorrow and see if that could be the issue.

           

          Mike

           

           

          package flexUnitTests.flexUnit1.framework

          {

           

            import flexunit.framework.TestSuite;

           

            public class AllFrameworkTests

            {

              public static function suite() : TestSuite

              {

                var testSuite:TestSuite = new TestSuite();

           

                testSuite.addTestSuite( TestAssert );

                testSuite.addTestSuite( TestTestCase );

                testSuite.addTestSuite( TestTestListener );

                testSuite.addTestSuite( TestEventfulTestCase );

                testSuite.addTestSuite( TestAsynchronous );

           

                return testSuite;

            }

            }

          }

          • 2. Re: Running Old TestSuite in new Framework
            rrsIPOV2 Level 1

            Thanks.  The old TestSuite I was trying to run did not have a suite() method.  I added one looking like:

             

            public static function suite(params:Object = null):TestSuite {
                return new MyTestSuite(params);
            }
            

             

            And the TestRunner is now working.  I guess I had tried to make my previous attempts too complex, invoking SuiteMethod directly (and undoubtly incorrectly).